diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7bd2e36..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-10T00:29:41.008Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 83c971a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dmidrange) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 9cede8e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dmidrange) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4cc69ef..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '20 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,120 +173,7 @@ console.log( v ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/stats/base/dmidrange.h" -``` - -#### stdlib_strided_dmidrange( N, \*X, strideX ) - -Computes the [mid-range][mid-range] of a double-precision floating-point strided array `x`. - -```c -const double x[] = { 1.0, 2.0, 3.0, 4.0 }; - -double v = stdlib_strided_dmidrange( 4, x, 1 ); -// returns 2.5 -``` - -The function accepts the following arguments: - -- **N**: `[in] CBLAS_INT` number of indexed elements. -- **X**: `[in] double*` input array. -- **strideX**: `[in] CBLAS_INT` stride length for `X`. - -```c -double stdlib_strided_dmidrange( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ); -``` - -#### stdlib_strided_dmidrange_ndarray( N, \*X, strideX, offsetX ) - -Computes the [mid-range][mid-range] of a double-precision floating-point strided array using alternative indexing semantics. - -```c -const double x[] = { 1.0, 2.0, 3.0, 4.0 }; - -double v = stdlib_strided_dmidrange_ndarray( 4, x, 1, 0 ); -// returns 2.5 -``` - -The function accepts the following arguments: - -- **N**: `[in] CBLAS_INT` number of indexed elements. -- **X**: `[in] double*` input array. -- **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **offsetX**: `[in] CBLAS_INT` starting index for `X`. - -```c -double stdlib_strided_dmidrange_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/stats/base/dmidrange.h" -#include - -int main( void ) { - // Create a strided array: - const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0 }; - - // Specify the number of elements: - const int N = 4; - - // Specify the stride length: - const int strideX = 2; - - // Compute the mid-range: - double v = stdlib_strided_dmidrange( N, x, strideX ); - - // Print the result: - printf( "mid-range: %lf\n", v ); -} -``` - -
- - - -
- @@ -324,7 +202,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -389,21 +267,21 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mid-range]: https://en.wikipedia.org/wiki/Mid-range -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[@stdlib/stats/strided/dmax]: https://github.com/stdlib-js/stats-strided-dmax +[@stdlib/stats/strided/dmax]: https://github.com/stdlib-js/stats-strided-dmax/tree/esm -[@stdlib/stats/base/dmean]: https://github.com/stdlib-js/stats-base-dmean +[@stdlib/stats/base/dmean]: https://github.com/stdlib-js/stats-base-dmean/tree/esm -[@stdlib/stats/base/dmin]: https://github.com/stdlib-js/stats-base-dmin +[@stdlib/stats/base/dmin]: https://github.com/stdlib-js/stats-base-dmin/tree/esm -[@stdlib/stats/base/drange]: https://github.com/stdlib-js/stats-base-drange +[@stdlib/stats/base/drange]: https://github.com/stdlib-js/stats-base-drange/tree/esm -[@stdlib/stats/base/smidrange]: https://github.com/stdlib-js/stats-base-smidrange +[@stdlib/stats/base/smidrange]: https://github.com/stdlib-js/stats-base-smidrange/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 944f744..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,96 +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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var dmidrange = require( './../lib/dmidrange.js' ); - - -// VARIABLES // - -var options = { - 'dtype': 'float64' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); - return benchmark; - - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = dmidrange( x.length, x, 1 ); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - 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/benchmark/benchmark.native.js b/benchmark/benchmark.native.js deleted file mode 100644 index 1fa72e7..0000000 --- a/benchmark/benchmark.native.js +++ /dev/null @@ -1,101 +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 resolve = require( 'path' ).resolve; -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var tryRequire = require( '@stdlib/utils-try-require' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var dmidrange = tryRequire( resolve( __dirname, './../lib/dmidrange.native.js' ) ); -var opts = { - 'skip': ( dmidrange instanceof Error ) -}; -var options = { - 'dtype': 'float64' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); - return benchmark; - - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = dmidrange( x.length, x, 1 ); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - 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+'::native:len='+len, opts, f ); - } -} - -main(); diff --git a/benchmark/benchmark.ndarray.js b/benchmark/benchmark.ndarray.js deleted file mode 100644 index 4cb1acf..0000000 --- a/benchmark/benchmark.ndarray.js +++ /dev/null @@ -1,96 +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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var dmidrange = require( './../lib/ndarray.js' ); - - -// VARIABLES // - -var options = { - 'dtype': 'float64' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); - return benchmark; - - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = dmidrange( x.length, x, 1, 0 ); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - 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+':ndarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.ndarray.native.js b/benchmark/benchmark.ndarray.native.js deleted file mode 100644 index b64afa0..0000000 --- a/benchmark/benchmark.ndarray.native.js +++ /dev/null @@ -1,101 +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 resolve = require( 'path' ).resolve; -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var tryRequire = require( '@stdlib/utils-try-require' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var dmidrange = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); -var opts = { - 'skip': ( dmidrange instanceof Error ) -}; -var options = { - 'dtype': 'float64' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); - return benchmark; - - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = dmidrange( x.length, x, 1, 0 ); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - 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+'::native:ndarray:len='+len, opts, f ); - } -} - -main(); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index 7280962..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.length.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.length.c b/benchmark/c/benchmark.length.c deleted file mode 100644 index e49f9d0..0000000 --- a/benchmark/c/benchmark.length.c +++ /dev/null @@ -1,197 +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. -*/ - -#include "stdlib/stats/base/dmidrange.h" -#include -#include -#include -#include -#include - -#define NAME "dmidrange" -#define ITERATIONS 1000000 -#define REPEATS 3 -#define MIN 1 -#define MAX 6 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param iterations number of iterations -* @param elapsed elapsed time in seconds -*/ -static void print_results( int iterations, double elapsed ) { - double rate = (double)iterations / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", iterations ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @param iterations number of iterations -* @param len array length -* @return elapsed time in seconds -*/ -static double benchmark1( int iterations, int len ) { - double elapsed; - double x[ len ]; - double v; - double t; - int i; - - for ( i = 0; i < len; i++ ) { - x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; - } - v = 0.0; - t = tic(); - for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - v = stdlib_strided_dmidrange( len, x, 1 ); - if ( v != v ) { - printf( "should not return NaN\n" ); - break; - } - } - elapsed = tic() - t; - if ( v != v ) { - printf( "should not return NaN\n" ); - } - return elapsed; -} - -/** -* Runs a benchmark. -* -* @param iterations number of iterations -* @param len array length -* @return elapsed time in seconds -*/ -static double benchmark2( int iterations, int len ) { - double elapsed; - double x[ len ]; - double v; - double t; - int i; - - for ( i = 0; i < len; i++ ) { - x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; - } - v = 0.0; - t = tic(); - for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - v = stdlib_strided_dmidrange_ndarray( len, x, 1, 0 ); - if ( v != v ) { - printf( "should not return NaN\n" ); - break; - } - } - elapsed = tic() - t; - if ( v != v ) { - printf( "should not return NaN\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int count; - int iter; - int len; - int i; - int j; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - count = 0; - for ( i = MIN; i <= MAX; i++ ) { - len = pow( 10, i ); - iter = ITERATIONS / pow( 10, i-1 ); - for ( j = 0; j < REPEATS; j++ ) { - count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark1( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); - } - } - for ( i = MIN; i <= MAX; i++ ) { - len = pow( 10, i ); - iter = ITERATIONS / pow( 10, i-1 ); - for ( j = 0; j < REPEATS; j++ ) { - count += 1; - printf( "# c::%s:ndarray:len=%d\n", NAME, len ); - elapsed = benchmark2( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); - } - } - print_summary( count, count ); -} diff --git a/binding.gyp b/binding.gyp deleted file mode 100644 index 7d0005b..0000000 --- a/binding.gyp +++ /dev/null @@ -1,170 +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. - -# A `.gyp` file for building a Node.js native add-on. -# -# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md -# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md -{ - # List of files to include in this file: - 'includes': [ - './include.gypi', - ], - - # Define variables to be used throughout the configuration for all targets: - 'variables': { - # Target name should match the add-on export name: - 'addon_target_name%': 'addon', - - # Set variables based on the host OS: - 'conditions': [ - [ - 'OS=="win"', - { - # Define the object file suffix: - 'obj': 'obj', - }, - { - # Define the object file suffix: - 'obj': 'o', - } - ], # end condition (OS=="win") - ], # end conditions - }, # end variables - - # Define compile targets: - 'targets': [ - - # Target to generate an add-on: - { - # The target name should match the add-on export name: - 'target_name': '<(addon_target_name)', - - # Define dependencies: - 'dependencies': [], - - # Define directories which contain relevant include headers: - 'include_dirs': [ - # Local include directory: - '<@(include_dirs)', - ], - - # List of source files: - 'sources': [ - '<@(src_files)', - ], - - # Settings which should be applied when a target's object files are used as linker input: - 'link_settings': { - # Define libraries: - 'libraries': [ - '<@(libraries)', - ], - - # Define library directories: - 'library_dirs': [ - '<@(library_dirs)', - ], - }, - - # C/C++ compiler flags: - 'cflags': [ - # Enable commonly used warning options: - '-Wall', - - # Aggressive optimization: - '-O3', - ], - - # C specific compiler flags: - 'cflags_c': [ - # Specify the C standard to which a program is expected to conform: - '-std=c99', - ], - - # C++ specific compiler flags: - 'cflags_cpp': [ - # Specify the C++ standard to which a program is expected to conform: - '-std=c++11', - ], - - # Linker flags: - 'ldflags': [], - - # Apply conditions based on the host OS: - 'conditions': [ - [ - 'OS=="mac"', - { - # Linker flags: - 'ldflags': [ - '-undefined dynamic_lookup', - '-Wl,-no-pie', - '-Wl,-search_paths_first', - ], - }, - ], # end condition (OS=="mac") - [ - 'OS!="win"', - { - # C/C++ flags: - 'cflags': [ - # Generate platform-independent code: - '-fPIC', - ], - }, - ], # end condition (OS!="win") - ], # end conditions - }, # end target <(addon_target_name) - - # Target to copy a generated add-on to a standard location: - { - 'target_name': 'copy_addon', - - # Declare that the output of this target is not linked: - 'type': 'none', - - # Define dependencies: - 'dependencies': [ - # Require that the add-on be generated before building this target: - '<(addon_target_name)', - ], - - # Define a list of actions: - 'actions': [ - { - 'action_name': 'copy_addon', - 'message': 'Copying addon...', - - # Explicitly list the inputs in the command-line invocation below: - 'inputs': [], - - # Declare the expected outputs: - 'outputs': [ - '<(addon_output_dir)/<(addon_target_name).node', - ], - - # Define the command-line invocation: - 'action': [ - 'cp', - '<(PRODUCT_DIR)/<(addon_target_name).node', - '<(addon_output_dir)/<(addon_target_name).node', - ], - }, - ], # end actions - }, # end target copy_addon - ], # end targets -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 23192eb..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dmidrange" -%% click B href "https://github.com/stdlib-js/stats-base-dmidrange/tree/main" -%% click C href "https://github.com/stdlib-js/stats-base-dmidrange/tree/production" -%% click D href "https://github.com/stdlib-js/stats-base-dmidrange/tree/esm" -%% click E href "https://github.com/stdlib-js/stats-base-dmidrange/tree/deno" -%% click F href "https://github.com/stdlib-js/stats-base-dmidrange/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dmidrange -[production-url]: https://github.com/stdlib-js/stats-base-dmidrange/tree/production -[deno-url]: https://github.com/stdlib-js/stats-base-dmidrange/tree/deno -[deno-readme]: https://github.com/stdlib-js/stats-base-dmidrange/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/stats-base-dmidrange/tree/umd -[umd-readme]: https://github.com/stdlib-js/stats-base-dmidrange/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/stats-base-dmidrange/tree/esm -[esm-readme]: https://github.com/stdlib-js/stats-base-dmidrange/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8640613..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import dmidrange from '../docs/types/index'; -export = dmidrange; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c32d009..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var s=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var o=s(function(B,f){ -var j=require('@stdlib/math-base-assert-is-positive-zero/dist'),l=require('@stdlib/math-base-assert-is-negative-zero/dist'),R=require('@stdlib/math-base-assert-is-nan/dist');function Z(i,e,n,d){var t,a,u,r,v;if(i<=0)return NaN;if(i===1||n===0)return e[d];for(u=d,a=e[u],t=a,v=1;vt||r===t&&j(r))&&(t=r)}return(t+a)/2}f.exports=Z -});var c=s(function(C,m){ -var _=require('@stdlib/strided-base-stride2offset/dist'),E=o();function O(i,e,n){return E(i,e,n,_(i,n))}m.exports=O -});var y=s(function(D,p){ -var P=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),b=o();P(g,"ndarray",b);p.exports=g -});var h=require("path").join,k=require('@stdlib/utils-try-require/dist'),w=require('@stdlib/assert-is-error/dist'),z=y(),q,x=k(h(__dirname,"./native.js"));w(x)?q=z:q=x;module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 31d7623..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/ndarray.js", "../lib/dmidrange.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\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\nvar isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Computes the mid-range of a double-precision floating-point strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {number} mid-range\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );\n*\n* var v = dmidrange( 4, x, 2, 1 );\n* // returns 1.0\n*/\nfunction dmidrange( N, x, strideX, offsetX ) {\n\tvar max;\n\tvar min;\n\tvar ix;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn NaN;\n\t}\n\tif ( N === 1 || strideX === 0 ) {\n\t\treturn x[ offsetX ];\n\t}\n\tix = offsetX;\n\tmin = x[ ix ];\n\tmax = min;\n\tfor ( i = 1; i < N; i++ ) {\n\t\tix += strideX;\n\t\tv = x[ ix ];\n\t\tif ( isnan( v ) ) {\n\t\t\treturn v;\n\t\t}\n\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\tmin = v;\n\t\t} else if ( v > max || ( v === max && isPositiveZero( v ) ) ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn ( max+min ) / 2.0;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dmidrange;\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\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Computes the mid-range of a double-precision floating-point strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - input array\n* @param {integer} strideX - stride length\n* @returns {number} mid-range\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );\n*\n* var v = dmidrange( x.length, x, 1 );\n* // returns 0.0\n*/\nfunction dmidrange( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dmidrange;\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\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dmidrange = require( './dmidrange.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dmidrange, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dmidrange;\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* Compute the mid-range of a double-precision floating-point strided array.\n*\n* @module @stdlib/stats-base-dmidrange\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dmidrange = require( '@stdlib/stats-base-dmidrange' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );\n*\n* var v = dmidrange( x.length, x, 1 );\n* // returns 0.0\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var dmidrange = require( '@stdlib/stats-base-dmidrange' );\n*\n* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );\n*\n* var v = dmidrange.ndarray( 4, x, 2, 1 );\n* // returns 1.0\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dmidrange;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdmidrange = main;\n} else {\n\tdmidrange = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dmidrange;\n\n// exports: { \"ndarray\": \"dmidrange.ndarray\" }\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,2CAA4C,EACtEC,EAAiB,QAAS,2CAA4C,EACtEC,EAAQ,QAAS,iCAAkC,EAsBvD,SAASC,EAAWC,EAAGC,EAAGC,EAASC,EAAU,CAC5C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKR,GAAK,EACT,MAAO,KAER,GAAKA,IAAM,GAAKE,IAAY,EAC3B,OAAOD,EAAGE,CAAQ,EAKnB,IAHAG,EAAKH,EACLE,EAAMJ,EAAGK,CAAG,EACZF,EAAMC,EACAG,EAAI,EAAGA,EAAIR,EAAGQ,IAAM,CAGzB,GAFAF,GAAMJ,EACNK,EAAIN,EAAGK,CAAG,EACLR,EAAOS,CAAE,EACb,OAAOA,EAEHA,EAAIF,GAASE,IAAMF,GAAOR,EAAgBU,CAAE,EAChDF,EAAME,GACKA,EAAIH,GAASG,IAAMH,GAAOR,EAAgBW,CAAE,KACvDH,EAAMG,EAER,CACA,OAASH,EAAIC,GAAQ,CACtB,CAKAV,EAAO,QAAUI,IChFjB,IAAAU,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAqBd,SAASC,EAAWC,EAAGC,EAAGC,EAAU,CACnC,OAAOJ,EAASE,EAAGC,EAAGC,EAASL,EAAeG,EAAGE,CAAQ,CAAE,CAC5D,CAKAN,EAAO,QAAUG,ICnDjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,IACZC,EAAU,IAKdF,EAAaC,EAAW,UAAWC,CAAQ,EAK3CH,EAAO,QAAUE,ICajB,IAAIE,EAAO,QAAS,MAAO,EAAE,KACzBC,EAAa,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAYD,EAEZC,EAAYC,EAMb,OAAO,QAAUD", - "names": ["require_ndarray", "__commonJSMin", "exports", "module", "isPositiveZero", "isNegativeZero", "isnan", "dmidrange", "N", "x", "strideX", "offsetX", "max", "min", "ix", "v", "i", "require_dmidrange", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dmidrange", "N", "x", "strideX", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dmidrange", "ndarray", "join", "tryRequire", "isError", "main", "dmidrange", "tmp"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b32cd66..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,89 +0,0 @@ - -{{alias}}( N, x, strideX ) - Computes the mid-range of a double-precision floating-point strided array. - - The `N` and stride parameters determine which elements in `x` are accessed - at runtime. - - Indexing is relative to the first index. To introduce an offset, use a typed - array view. - - If `N <= 0`, the function returns `NaN`. - - Parameters - ---------- - N: integer - Number of indexed elements. - - x: Float64Array - Input array. - - strideX: integer - Stride length. - - Returns - ------- - out: number - Mid-range. - - Examples - -------- - // Standard Usage: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); - > {{alias}}( x.length, x, 1 ) - 0.0 - - // Using `N` and stride parameters: - > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > {{alias}}( 3, x, 2 ) - 0.0 - - // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 3, x1, 2 ) - 0.0 - - -{{alias}}.ndarray( N, x, strideX, offsetX ) - Computes the mid-range of a double-precision floating-point strided array - using alternative indexing semantics. - - While typed array views mandate a view offset based on the underlying - buffer, the `offset` parameter supports indexing semantics based on a - starting index. - - Parameters - ---------- - N: integer - Number of indexed elements. - - x: Float64Array - Input array. - - strideX: integer - Stride length. - - offsetX: integer - Starting index. - - Returns - ------- - out: number - Mid-range. - - Examples - -------- - // Standard Usage: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); - > {{alias}}.ndarray( x.length, x, 1, 0 ) - 0.0 - - // Using offset parameter: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > {{alias}}.ndarray( 3, x, 2, 1 ) - 0.0 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 9a430ba..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,157 +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 dmidrange = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - const x = new Float64Array( 10 ); - - dmidrange( x.length, x, 1 ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - const x = new Float64Array( 10 ); - - dmidrange( '10', x, 1 ); // $ExpectError - dmidrange( true, x, 1 ); // $ExpectError - dmidrange( false, x, 1 ); // $ExpectError - dmidrange( null, x, 1 ); // $ExpectError - dmidrange( undefined, x, 1 ); // $ExpectError - dmidrange( [], x, 1 ); // $ExpectError - dmidrange( {}, x, 1 ); // $ExpectError - dmidrange( ( x: number ): number => x, x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a Float64Array... -{ - const x = new Float64Array( 10 ); - - dmidrange( x.length, 10, 1 ); // $ExpectError - dmidrange( x.length, '10', 1 ); // $ExpectError - dmidrange( x.length, true, 1 ); // $ExpectError - dmidrange( x.length, false, 1 ); // $ExpectError - dmidrange( x.length, null, 1 ); // $ExpectError - dmidrange( x.length, undefined, 1 ); // $ExpectError - dmidrange( x.length, [], 1 ); // $ExpectError - dmidrange( x.length, {}, 1 ); // $ExpectError - dmidrange( x.length, ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = new Float64Array( 10 ); - - dmidrange( x.length, x, '10' ); // $ExpectError - dmidrange( x.length, x, true ); // $ExpectError - dmidrange( x.length, x, false ); // $ExpectError - dmidrange( x.length, x, null ); // $ExpectError - dmidrange( x.length, x, undefined ); // $ExpectError - dmidrange( x.length, x, [] ); // $ExpectError - dmidrange( x.length, x, {} ); // $ExpectError - dmidrange( x.length, x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = new Float64Array( 10 ); - - dmidrange(); // $ExpectError - dmidrange( x.length ); // $ExpectError - dmidrange( x.length, x ); // $ExpectError - dmidrange( x.length, x, 1, 10 ); // $ExpectError -} - -// Attached to main export is an `ndarray` method which returns a number... -{ - const x = new Float64Array( 10 ); - - dmidrange.ndarray( x.length, x, 1, 0 ); // $ExpectType number -} - -// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... -{ - const x = new Float64Array( 10 ); - - dmidrange.ndarray( '10', x, 1, 0 ); // $ExpectError - dmidrange.ndarray( true, x, 1, 0 ); // $ExpectError - dmidrange.ndarray( false, x, 1, 0 ); // $ExpectError - dmidrange.ndarray( null, x, 1, 0 ); // $ExpectError - dmidrange.ndarray( undefined, x, 1, 0 ); // $ExpectError - dmidrange.ndarray( [], x, 1, 0 ); // $ExpectError - dmidrange.ndarray( {}, x, 1, 0 ); // $ExpectError - dmidrange.ndarray( ( x: number ): number => x, x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... -{ - const x = new Float64Array( 10 ); - - dmidrange.ndarray( x.length, 10, 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, '10', 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, true, 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, false, 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, null, 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, undefined, 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, [], 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, {}, 1, 0 ); // $ExpectError - dmidrange.ndarray( x.length, ( x: number ): number => x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... -{ - const x = new Float64Array( 10 ); - - dmidrange.ndarray( x.length, x, '10', 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, true, 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, false, 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, null, 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, undefined, 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, [], 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, {}, 0 ); // $ExpectError - dmidrange.ndarray( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... -{ - const x = new Float64Array( 10 ); - - dmidrange.ndarray( x.length, x, 1, '10' ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, true ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, false ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, null ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, undefined ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, [] ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, {} ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... -{ - const x = new Float64Array( 10 ); - - dmidrange.ndarray(); // $ExpectError - dmidrange.ndarray( x.length ); // $ExpectError - dmidrange.ndarray( x.length, x ); // $ExpectError - dmidrange.ndarray( x.length, x, 1 ); // $ExpectError - dmidrange.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 766ea11..0000000 --- a/examples/c/example.c +++ /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. -*/ - -#include "stdlib/stats/base/dmidrange.h" -#include - -int main( void ) { - // Create a strided array: - const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0 }; - - // Specify the number of elements: - const int N = 4; - - // Specify the stride length: - const int strideX = 2; - - // Compute the mid-range: - double v = stdlib_strided_dmidrange( N, x, strideX ); - - // Print the result: - printf( "mid-range: %lf\n", v ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a8fdbec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +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-array-discrete-uniform' ); -var dmidrange = require( './../lib' ); - -var x = discreteUniform( 10, -50, 50, { - 'dtype': 'float64' -}); -console.log( x ); - -var v = dmidrange( x.length, x, 1 ); -console.log( v ); diff --git a/include.gypi b/include.gypi deleted file mode 100644 index 9212937..0000000 --- a/include.gypi +++ /dev/null @@ -1,53 +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. - -# A GYP include file for building a Node.js native add-on. -# -# Main documentation: -# -# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md -# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md -{ - # Define variables to be used throughout the configuration for all targets: - 'variables': { - # Source directory: - 'src_dir': './src', - - # Include directories: - 'include_dirs': [ - ' +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-stride2offset@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-positive-zero@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-negative-zero@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.2-esm/index.mjs";function n(s,e,n,d){var m,a,o,f,j;if(s<=0)return NaN;if(1===s||0===n)return e[d];for(m=a=e[o=d],j=1;jm||f===m&&t(f))&&(m=f)}return(m+a)/2}function d(s,t,r){return n(s,t,r,e(s,r))}s(d,"ndarray",n);export{d as default,n as ndarray}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fa9521 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/ndarray.js","../lib/dmidrange.js","../lib/main.js"],"sourcesContent":["/**\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 isPositiveZero from '@stdlib/math-base-assert-is-positive-zero';\nimport isNegativeZero from '@stdlib/math-base-assert-is-negative-zero';\nimport isnan from '@stdlib/math-base-assert-is-nan';\n\n\n// MAIN //\n\n/**\n* Computes the mid-range of a double-precision floating-point strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {number} mid-range\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );\n*\n* var v = dmidrange( 4, x, 2, 1 );\n* // returns 1.0\n*/\nfunction dmidrange( N, x, strideX, offsetX ) {\n\tvar max;\n\tvar min;\n\tvar ix;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn NaN;\n\t}\n\tif ( N === 1 || strideX === 0 ) {\n\t\treturn x[ offsetX ];\n\t}\n\tix = offsetX;\n\tmin = x[ ix ];\n\tmax = min;\n\tfor ( i = 1; i < N; i++ ) {\n\t\tix += strideX;\n\t\tv = x[ ix ];\n\t\tif ( isnan( v ) ) {\n\t\t\treturn v;\n\t\t}\n\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\tmin = v;\n\t\t} else if ( v > max || ( v === max && isPositiveZero( v ) ) ) {\n\t\t\tmax = v;\n\t\t}\n\t}\n\treturn ( max+min ) / 2.0;\n}\n\n\n// EXPORTS //\n\nexport default dmidrange;\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* Computes the mid-range of a double-precision floating-point strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - input array\n* @param {integer} strideX - stride length\n* @returns {number} mid-range\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );\n*\n* var v = dmidrange( x.length, x, 1 );\n* // returns 0.0\n*/\nfunction dmidrange( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nexport default dmidrange;\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 setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport dmidrange from './dmidrange.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( dmidrange, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default dmidrange;\n"],"names":["dmidrange","N","x","strideX","offsetX","max","min","ix","v","i","NaN","isnan","isNegativeZero","isPositiveZero","ndarray","stride2offset","setReadOnly"],"mappings":";;uhBA8CA,SAASA,EAAWC,EAAGC,EAAGC,EAASC,GAClC,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKR,GAAK,EACT,OAAOS,IAER,GAAW,IAANT,GAAuB,IAAZE,EACf,OAAOD,EAAGE,GAKX,IADAC,EADAC,EAAMJ,EADNK,EAAKH,GAGCK,EAAI,EAAGA,EAAIR,EAAGQ,IAAM,CAGzB,GADAD,EAAIN,EADJK,GAAMJ,GAEDQ,EAAOH,GACX,OAAOA,EAEHA,EAAIF,GAASE,IAAMF,GAAOM,EAAgBJ,GAC9CF,EAAME,GACKA,EAAIH,GAASG,IAAMH,GAAOQ,EAAgBL,MACrDH,EAAMG,EAEP,CACD,OAASH,EAAIC,GAAQ,CACtB,CC/BA,SAASN,EAAWC,EAAGC,EAAGC,GACzB,OAAOW,EAASb,EAAGC,EAAGC,EAASY,EAAed,EAAGE,GAClD,CCjBAa,EAAAhB,EAAA,UAAAc"} \ No newline at end of file diff --git a/lib/dmidrange.js b/lib/dmidrange.js deleted file mode 100644 index 50920d3..0000000 --- a/lib/dmidrange.js +++ /dev/null @@ -1,52 +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 stride2offset = require( '@stdlib/strided-base-stride2offset' ); -var ndarray = require( './ndarray.js' ); - - -// MAIN // - -/** -* Computes the mid-range of a double-precision floating-point strided array. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - input array -* @param {integer} strideX - stride length -* @returns {number} mid-range -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* -* var v = dmidrange( x.length, x, 1 ); -* // returns 0.0 -*/ -function dmidrange( N, x, strideX ) { - return ndarray( N, x, strideX, stride2offset( N, strideX ) ); -} - - -// EXPORTS // - -module.exports = dmidrange; diff --git a/lib/dmidrange.native.js b/lib/dmidrange.native.js deleted file mode 100644 index 75f7940..0000000 --- a/lib/dmidrange.native.js +++ /dev/null @@ -1,51 +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 addon = require( './../src/addon.node' ); - - -// MAIN // - -/** -* Computes the mid-range of a double-precision floating-point strided array. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - input array -* @param {integer} strideX - stride length -* @returns {number} mid-range -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* -* var v = dmidrange( x.length, x, 1 ); -* // returns 0.0 -*/ -function dmidrange( N, x, strideX ) { - return addon( N, x, strideX ); -} - - -// EXPORTS // - -module.exports = dmidrange; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2d7ef0e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,69 +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'; - -/** -* Compute the mid-range of a double-precision floating-point strided array. -* -* @module @stdlib/stats-base-dmidrange -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var dmidrange = require( '@stdlib/stats-base-dmidrange' ); -* -* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* -* var v = dmidrange( x.length, x, 1 ); -* // returns 0.0 -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var floor = require( '@stdlib/math-base-special-floor' ); -* var dmidrange = require( '@stdlib/stats-base-dmidrange' ); -* -* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* -* var v = dmidrange.ndarray( 4, x, 2, 1 ); -* // returns 1.0 -*/ - -// MODULES // - -var join = require( 'path' ).join; -var tryRequire = require( '@stdlib/utils-try-require' ); -var isError = require( '@stdlib/assert-is-error' ); -var main = require( './main.js' ); - - -// MAIN // - -var dmidrange; -var tmp = tryRequire( join( __dirname, './native.js' ) ); -if ( isError( tmp ) ) { - dmidrange = main; -} else { - dmidrange = tmp; -} - - -// EXPORTS // - -module.exports = dmidrange; - -// exports: { "ndarray": "dmidrange.ndarray" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 629d166..0000000 --- a/lib/main.js +++ /dev/null @@ -1,35 +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 setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var dmidrange = require( './dmidrange.js' ); -var ndarray = require( './ndarray.js' ); - - -// MAIN // - -setReadOnly( dmidrange, 'ndarray', ndarray ); - - -// EXPORTS // - -module.exports = dmidrange; diff --git a/lib/native.js b/lib/native.js deleted file mode 100644 index aae02a5..0000000 --- a/lib/native.js +++ /dev/null @@ -1,35 +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 setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var dmidrange = require( './dmidrange.native.js' ); -var ndarray = require( './ndarray.native.js' ); - - -// MAIN // - -setReadOnly( dmidrange, 'ndarray', ndarray ); - - -// EXPORTS // - -module.exports = dmidrange; diff --git a/lib/ndarray.js b/lib/ndarray.js deleted file mode 100644 index ac43166..0000000 --- a/lib/ndarray.js +++ /dev/null @@ -1,81 +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 isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' ); -var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); - - -// MAIN // - -/** -* Computes the mid-range of a double-precision floating-point strided array. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index -* @returns {number} mid-range -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* -* var v = dmidrange( 4, x, 2, 1 ); -* // returns 1.0 -*/ -function dmidrange( N, x, strideX, offsetX ) { - var max; - var min; - var ix; - var v; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || strideX === 0 ) { - return x[ offsetX ]; - } - ix = offsetX; - min = x[ ix ]; - max = min; - for ( i = 1; i < N; i++ ) { - ix += strideX; - v = x[ ix ]; - if ( isnan( v ) ) { - return v; - } - if ( v < min || ( v === min && isNegativeZero( v ) ) ) { - min = v; - } else if ( v > max || ( v === max && isPositiveZero( v ) ) ) { - max = v; - } - } - return ( max+min ) / 2.0; -} - - -// EXPORTS // - -module.exports = dmidrange; diff --git a/lib/ndarray.native.js b/lib/ndarray.native.js deleted file mode 100644 index a66ace0..0000000 --- a/lib/ndarray.native.js +++ /dev/null @@ -1,52 +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 addon = require( './../src/addon.node' ); - - -// MAIN // - -/** -* Computes the mid-range of a double-precision floating-point strided array. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - input array -* @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index -* @returns {number} mid-range -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -* -* var v = dmidrange( 4, x, 2, 1 ); -* // returns 1.0 -*/ -function dmidrange( N, x, strideX, offsetX ) { - return addon.ndarray( N, x, strideX, offsetX ); -} - - -// EXPORTS // - -module.exports = dmidrange; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index c1e0631..0000000 --- a/manifest.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "options": { - "task": "build", - "wasm": false - }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "wasm": false, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas-base-shared", - "@stdlib/strided-base-stride2offset", - "@stdlib/math-base-assert-is-positive-zero", - "@stdlib/math-base-assert-is-negative-zero", - "@stdlib/math-base-assert-is-nan", - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float64array", - "@stdlib/napi-create-double" - ] - }, - { - "task": "benchmark", - "wasm": false, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas-base-shared", - "@stdlib/strided-base-stride2offset", - "@stdlib/math-base-assert-is-nan", - "@stdlib/math-base-assert-is-positive-zero", - "@stdlib/math-base-assert-is-negative-zero" - ] - }, - { - "task": "examples", - "wasm": false, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas-base-shared", - "@stdlib/strided-base-stride2offset", - "@stdlib/math-base-assert-is-nan", - "@stdlib/math-base-assert-is-positive-zero", - "@stdlib/math-base-assert-is-negative-zero" - ] - }, - { - "task": "", - "wasm": true, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/blas-base-shared", - "@stdlib/strided-base-stride2offset", - "@stdlib/math-base-assert-is-nan", - "@stdlib/math-base-assert-is-positive-zero", - "@stdlib/math-base-assert-is-negative-zero" - ] - } - ] -} diff --git a/package.json b/package.json index 07d89f1..97ea22f 100644 --- a/package.json +++ b/package.json @@ -3,35 +3,8 @@ "version": "0.2.2", "description": "Calculate the mid-range of a double-precision floating-point strided 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", - "browser": "./lib/main.js", - "gypfile": false, - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -40,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/blas-base-shared": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-assert-is-negative-zero": "^0.2.2", - "@stdlib/math-base-assert-is-positive-zero": "^0.2.2", - "@stdlib/napi-argv": "^0.2.2", - "@stdlib/napi-argv-int64": "^0.2.2", - "@stdlib/napi-argv-strided-float64array": "^0.2.2", - "@stdlib/napi-create-double": "^0.0.2", - "@stdlib/napi-export": "^0.2.2", - "@stdlib/strided-base-stride2offset": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/utils-try-require": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-array-uniform": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdmath", @@ -109,7 +39,6 @@ "double", "float64array" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index dd720a3..0000000 --- a/src/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - - -# RULES # - -#/ -# Removes generated files for building an add-on. -# -# @example -# make clean-addon -#/ -clean-addon: - $(QUIET) -rm -f *.o *.node - -.PHONY: clean-addon - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: clean-addon - -.PHONY: clean diff --git a/src/addon.c b/src/addon.c deleted file mode 100644 index 5889e6a..0000000 --- a/src/addon.c +++ /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. -*/ - -#include "stdlib/stats/base/dmidrange.h" -#include "stdlib/blas/base/shared.h" -#include "stdlib/napi/export.h" -#include "stdlib/napi/argv.h" -#include "stdlib/napi/argv_int64.h" -#include "stdlib/napi/argv_strided_float64array.h" -#include "stdlib/napi/create_double.h" -#include - -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -static napi_value addon( napi_env env, napi_callback_info info ) { - STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); - STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dmidrange)( N, X, strideX ), v ); - return v; -} - -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -static napi_value addon_method( napi_env env, napi_callback_info info ) { - STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); - STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dmidrange_ndarray)( N, X, strideX, offsetX ), v ); - return v; -} - -STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 92d1c04..0000000 --- a/src/main.c +++ /dev/null @@ -1,77 +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. -*/ - -#include "stdlib/stats/base/dmidrange.h" -#include "stdlib/math/base/assert/is_nan.h" -#include "stdlib/math/base/assert/is_positive_zero.h" -#include "stdlib/math/base/assert/is_negative_zero.h" -#include "stdlib/blas/base/shared.h" -#include "stdlib/strided/base/stride2offset.h" - -/** -* Computes the mid-range of a double-precision floating-point strided array. -* -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return output value -*/ -double API_SUFFIX(stdlib_strided_dmidrange)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) { - const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); - return API_SUFFIX(stdlib_strided_dmidrange_ndarray)( N, X, strideX, ox ); -} - -/** -* Computes the mid-range of a double-precision floating-point strided array using alternative indexing semantics. -* -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index for X -* @return output value -*/ -double API_SUFFIX(stdlib_strided_dmidrange_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { - CBLAS_INT ix; - CBLAS_INT i; - double max; - double min; - double v; - - if ( N <= 0 ) { - return 0.0 / 0.0; // NaN - } - if ( N == 1 || strideX == 0 ) { - return X[ offsetX ]; - } - ix = offsetX; - min = X[ ix ]; - max = min; - for ( i = 1; i < N; i++ ) { - ix += strideX; - v = X[ ix ]; - if ( stdlib_base_is_nan( v ) ) { - return v; - } - if ( v < min || ( v == min && stdlib_base_is_negative_zero( v ) ) ) { - min = v; - } else if ( v > max || ( v == max && stdlib_base_is_positive_zero( v ) ) ) { - max = v; - } - } - return ( max+min ) / 2.0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cdc342f --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.dmidrange.js b/test/test.dmidrange.js deleted file mode 100644 index 7b5dd50..0000000 --- a/test/test.dmidrange.js +++ /dev/null @@ -1,184 +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 tape = require( 'tape' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' ); -var Float64Array = require( '@stdlib/array-float64' ); -var dmidrange = require( './../lib/dmidrange.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dmidrange, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( dmidrange.length, 3, 'has expected arity' ); - t.end(); -}); - -tape( 'the function calculates the mid-range of a strided array', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( v, 0.5, 'returns expected value' ); - - x = new Float64Array( [ -4.0, -5.0 ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( v, -4.5, 'returns expected value' ); - - x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN, NaN ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 0, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = dmidrange( -1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a `stride` parameter', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]); - - v = dmidrange( 4, x, 2 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]); - - v = dmidrange( 4, x, -2 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports view offsets', function test( t ) { - var x0; - var x1; - var v; - - x0 = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0, // 3 - 6.0 - ]); - - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - - v = dmidrange( 4, x1, 2 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.dmidrange.native.js b/test/test.dmidrange.native.js deleted file mode 100644 index 5d346ac..0000000 --- a/test/test.dmidrange.native.js +++ /dev/null @@ -1,193 +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 resolve = require( 'path' ).resolve; -var tape = require( 'tape' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' ); -var Float64Array = require( '@stdlib/array-float64' ); -var tryRequire = require( '@stdlib/utils-try-require' ); - - -// VARIABLES // - -var dmidrange = tryRequire( resolve( __dirname, './../lib/dmidrange.native.js' ) ); -var opts = { - 'skip': ( dmidrange instanceof Error ) -}; - - -// TESTS // - -tape( 'main export is a function', opts, function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dmidrange, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 3', opts, function test( t ) { - t.strictEqual( dmidrange.length, 3, 'has expected arity' ); - t.end(); -}); - -tape( 'the function calculates the mid-range of a strided array', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( v, 0.5, 'returns expected value' ); - - x = new Float64Array( [ -4.0, -5.0 ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( v, -4.5, 'returns expected value' ); - - x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN, NaN ] ); - v = dmidrange( x.length, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 0, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = dmidrange( -1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]); - - v = dmidrange( 4, x, 2 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]); - - v = dmidrange( 4, x, -2 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports view offsets', opts, function test( t ) { - var x0; - var x1; - var v; - - x0 = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0, // 3 - 6.0 - ]); - - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - - v = dmidrange( 4, x1, 2 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3c3bdb0..0000000 --- a/test/test.js +++ /dev/null @@ -1,82 +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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var dmidrange = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': IS_BROWSER -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dmidrange, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { - t.strictEqual( typeof dmidrange.ndarray, 'function', 'method is a function' ); - t.end(); -}); - -tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { - var dmidrange = proxyquire( './../lib', { - '@stdlib/utils-try-require': tryRequire - }); - - t.strictEqual( dmidrange, mock, 'returns expected value' ); - t.end(); - - function tryRequire() { - return mock; - } - - function mock() { - // Mock... - } -}); - -tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { - var dmidrange; - var main; - - main = require( './../lib/dmidrange.js' ); - - dmidrange = proxyquire( './../lib', { - '@stdlib/utils-try-require': tryRequire - }); - - t.strictEqual( dmidrange, main, 'returns expected value' ); - t.end(); - - function tryRequire() { - return new Error( 'Cannot find module' ); - } -}); diff --git a/test/test.ndarray.js b/test/test.ndarray.js deleted file mode 100644 index fbfc2f3..0000000 --- a/test/test.ndarray.js +++ /dev/null @@ -1,180 +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 tape = require( 'tape' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' ); -var Float64Array = require( '@stdlib/array-float64' ); -var dmidrange = require( './../lib/ndarray.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dmidrange, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( dmidrange.length, 4, 'has expected arity' ); - t.end(); -}); - -tape( 'the function calculates the mid-range of a strided array', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( v, 0.5, 'returns expected value' ); - - x = new Float64Array( [ -4.0, -5.0 ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( v, -4.5, 'returns expected value' ); - - x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN, NaN ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 0, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = dmidrange( -1, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a `stride` parameter', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]); - - v = dmidrange( 4, x, 2, 0 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]); - - v = dmidrange( 4, x, -2, 6 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports an `offset` parameter', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 - ]); - - v = dmidrange( 4, x, 2, 1 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.ndarray.native.js b/test/test.ndarray.native.js deleted file mode 100644 index 0f47d09..0000000 --- a/test/test.ndarray.native.js +++ /dev/null @@ -1,189 +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 resolve = require( 'path' ).resolve; -var tape = require( 'tape' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' ); -var Float64Array = require( '@stdlib/array-float64' ); -var tryRequire = require( '@stdlib/utils-try-require' ); - - -// VARIABLES // - -var dmidrange = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); -var opts = { - 'skip': ( dmidrange instanceof Error ) -}; - - -// TESTS // - -tape( 'main export is a function', opts, function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dmidrange, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 4', opts, function test( t ) { - t.strictEqual( dmidrange.length, 4, 'has expected arity' ); - t.end(); -}); - -tape( 'the function calculates the mid-range of a strided array', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( v, 0.5, 'returns expected value' ); - - x = new Float64Array( [ -4.0, -5.0 ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( v, -4.5, 'returns expected value' ); - - x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = new Float64Array( [ NaN, NaN ] ); - v = dmidrange( x.length, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 0, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - v = dmidrange( -1, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( 1, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]); - - v = dmidrange( 4, x, 2, 0 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]); - - v = dmidrange( 4, x, -2, 6 ); - - t.strictEqual( v, 1.0, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', opts, function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); - - v = dmidrange( x.length, x, 0, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var x; - var v; - - x = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 - ]); - - v = dmidrange( 4, x, 2, 1 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -});