diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000000..8b9a45c415ab --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,25 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +BLAS: +- changed-files: + - any-glob-to-all-files: '**/blas/**/*' + +Math: +- changed-files: + - any-glob-to-all-files: '**/math/**/*' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 000000000000..94e11706f074 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,55 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Workflow name: +name: 'labeler' + +# Workflow triggers: +on: + pull_request_target: + +# Workflow jobs: +jobs: + + # Define a job which automatically labels pull requests based on the contents of the pull request: + labeler: + + # Define job name: + name: 'Labeler' + + # Only run this job if the pull request did not have label `automated-pr`: + if: contains(github.event.pull_request.labels.*.name, 'automated-pr') == false + + # Define job permissions: + permissions: + contents: read + pull-requests: write + + # Define the type of virtual host machine: + runs-on: ubuntu-latest + + # Define the sequence of job steps: + steps: + + # Automatically label pull requests: + - name: 'Automatically label pull requests' + # Pin action to full length commit SHA + uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 + with: + configuration-path: .github/labeler.yml + repo-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }} diff --git a/.github/workflows/lint_autofix.yml b/.github/workflows/lint_autofix.yml index 61b7aa1fb0b2..8745292fefe9 100644 --- a/.github/workflows/lint_autofix.yml +++ b/.github/workflows/lint_autofix.yml @@ -17,156 +17,156 @@ #/ # Workflow name: - name: lint_autofix - - # Workflow triggers: - on: - - # Allow the workflow to be triggered by other workflows - workflow_call: - # Define the input parameters for the workflow: - inputs: - pull_request_number: - description: 'PR number' - required: true - type: number - # Define the secrets accessible by the workflow: - secrets: - STDLIB_BOT_GITHUB_TOKEN: - description: 'GitHub token for stdlb-bot' - required: true - REPO_GITHUB_TOKEN: - description: 'GitHub token for accessing the repository' - required: true - STDLIB_BOT_GPG_PRIVATE_KEY: - description: 'GPG private key for stdlb-bot' - required: true - STDLIB_BOT_GPG_PASSPHRASE: - description: 'GPG passphrase for stdlb-bot' - required: true - - # Workflow jobs: - jobs: - - # Define a job for automatically fixing lint errors: - autofix: - - # Define a display name: - name: 'Fix lint errors' - - # Define the type of virtual host machine: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Get PR details: - - name: 'Get PR details' - id: pr-details - run: | - pr_response=$(curl -s \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \ - "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}") - - # Escape control characters: - pr_response=$(echo "$pr_response" | tr -d '\000-\031') - - # Extract the needed details: - pr_branch=$(echo "$pr_response" | jq -r '.head.ref') # PR's branch - pr_repo_full_name=$(echo "$pr_response" | jq -r '.head.repo.full_name') # PR's repo full name - - # Set outputs for the branch and repository: - echo "branch=$pr_branch" >> $GITHUB_OUTPUT - echo "repository=$pr_repo_full_name" >> $GITHUB_OUTPUT - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - # Refers to the branch name of the branch being pushed: - ref: ${{ steps.pr-details.outputs.branch }} - - # Refers to the repository name: - repository: ${{ steps.pr-details.outputs.repository }} - - # Token for accessing the repository: - token: ${{ secrets.REPO_GITHUB_TOKEN }} - - # File path to checkout to: - path: './' - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: '20' # 'lts/*' - timeout-minutes: 5 - - # Install dependencies (accounting for possible network failures, etc, when installing node module dependencies): - - name: 'Install dependencies' - run: | - make install-node-modules || make install-node-modules || make install-node-modules - timeout-minutes: 15 - - # Initialize development environment: - - name: 'Initialize development environment' - run: | - make init - timeout-minutes: 5 - - # Get list of changed files: - - name: 'Get list of changed files' - id: changed-files - run: | - page=1 - files="" - while true; do - changed_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN - }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}/files?page=$page&per_page=100" | jq -r '.[] | .filename') - if [ -z "$changed_files" ]; then - break - fi - files="$files $changed_files" - page=$((page+1)) - done - files=$(echo "$files" | tr '\n' ' ' | sed 's/^ //;s/ $//') - echo "files=${files}" >> $GITHUB_OUTPUT - - # Fix JavaScript lint errors: - - name: 'Fix JavaScript lint errors' - id: fix-lint-errors - run: | - files="${{ steps.changed-files.outputs.files }}" - FIX=1 . "$GITHUB_WORKSPACE/.github/workflows/scripts/lint_javascript_files" "$files" - - # Disable Git hooks: - - name: 'Disable Git hooks' - run: | - rm -rf .git/hooks - - # Import GPG key to sign commits: - - name: 'Import GPG key to sign commits' - # Pin action to full length commit SHA - uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 - with: - gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }} - git_user_signingkey: true - git_commit_gpgsign: true - - # Commit and push changes: - - name: 'Commit and push changes' - env: - REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} - USER_NAME: stdlb-bot - BRANCH_NAME: ${{ steps.pr-details.outputs.branch }} - REPO_NAME: ${{ steps.pr-details.outputs.repository }} - run: | - git config --local user.email "82920195+stdlib-bot@users.noreply.github.com" - git config --local user.name "stdlib-bot" - git add . - git commit -m "fix: resolve lint errors" - git push "https://$USER_NAME:$REPO_GITHUB_TOKEN@github.com/$REPO_NAME.git" $BRANCH_NAME +name: lint_autofix + +# Workflow triggers: +on: + + # Allow the workflow to be triggered by other workflows + workflow_call: + # Define the input parameters for the workflow: + inputs: + pull_request_number: + description: 'PR number' + required: true + type: number + # Define the secrets accessible by the workflow: + secrets: + STDLIB_BOT_GITHUB_TOKEN: + description: 'GitHub token for stdlb-bot' + required: true + REPO_GITHUB_TOKEN: + description: 'GitHub token for accessing the repository' + required: true + STDLIB_BOT_GPG_PRIVATE_KEY: + description: 'GPG private key for stdlb-bot' + required: true + STDLIB_BOT_GPG_PASSPHRASE: + description: 'GPG passphrase for stdlb-bot' + required: true + +# Workflow jobs: +jobs: + + # Define a job for automatically fixing lint errors: + autofix: + + # Define a display name: + name: 'Fix lint errors' + + # Define the type of virtual host machine: + runs-on: ubuntu-latest + + # Define the sequence of job steps... + steps: + + # Get PR details: + - name: 'Get PR details' + id: pr-details + run: | + pr_response=$(curl -s \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \ + "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}") + + # Escape control characters: + pr_response=$(echo "$pr_response" | tr -d '\000-\031') + + # Extract the needed details: + pr_branch=$(echo "$pr_response" | jq -r '.head.ref') # PR's branch + pr_repo_full_name=$(echo "$pr_response" | jq -r '.head.repo.full_name') # PR's repo full name + + # Set outputs for the branch and repository: + echo "branch=$pr_branch" >> $GITHUB_OUTPUT + echo "repository=$pr_repo_full_name" >> $GITHUB_OUTPUT + + # Checkout the repository: + - name: 'Checkout repository' + # Pin action to full length commit SHA + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + # Refers to the branch name of the branch being pushed: + ref: ${{ steps.pr-details.outputs.branch }} + + # Refers to the repository name: + repository: ${{ steps.pr-details.outputs.repository }} + + # Token for accessing the repository: + token: ${{ secrets.REPO_GITHUB_TOKEN }} + + # File path to checkout to: + path: './' + + # Install Node.js: + - name: 'Install Node.js' + # Pin action to full length commit SHA + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: '20' # 'lts/*' + timeout-minutes: 5 + + # Install dependencies (accounting for possible network failures, etc, when installing node module dependencies): + - name: 'Install dependencies' + run: | + make install-node-modules || make install-node-modules || make install-node-modules + timeout-minutes: 15 + + # Initialize development environment: + - name: 'Initialize development environment' + run: | + make init + timeout-minutes: 5 + + # Get list of changed files: + - name: 'Get list of changed files' + id: changed-files + run: | + page=1 + files="" + while true; do + changed_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN + }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}/files?page=$page&per_page=100" | jq -r '.[] | .filename') + if [ -z "$changed_files" ]; then + break + fi + files="$files $changed_files" + page=$((page+1)) + done + files=$(echo "$files" | tr '\n' ' ' | sed 's/^ //;s/ $//') + echo "files=${files}" >> $GITHUB_OUTPUT + + # Fix JavaScript lint errors: + - name: 'Fix JavaScript lint errors' + id: fix-lint-errors + run: | + files="${{ steps.changed-files.outputs.files }}" + FIX=1 . "$GITHUB_WORKSPACE/.github/workflows/scripts/lint_javascript_files" "$files" + + # Disable Git hooks: + - name: 'Disable Git hooks' + run: | + rm -rf .git/hooks + + # Import GPG key to sign commits: + - name: 'Import GPG key to sign commits' + # Pin action to full length commit SHA + uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 + with: + gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + + # Commit and push changes: + - name: 'Commit and push changes' + env: + REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} + USER_NAME: stdlb-bot + BRANCH_NAME: ${{ steps.pr-details.outputs.branch }} + REPO_NAME: ${{ steps.pr-details.outputs.repository }} + run: | + git config --local user.email "82920195+stdlib-bot@users.noreply.github.com" + git config --local user.name "stdlib-bot" + git add . + git commit -m "fix: resolve lint errors" + git push "https://$USER_NAME:$REPO_GITHUB_TOKEN@github.com/$REPO_NAME.git" $BRANCH_NAME diff --git a/.github/workflows/lint_random_files.yml b/.github/workflows/lint_random_files.yml index c753ee425e53..b84b6417c749 100644 --- a/.github/workflows/lint_random_files.yml +++ b/.github/workflows/lint_random_files.yml @@ -316,7 +316,7 @@ jobs: # Pin action to full length commit SHA uses: r-lib/actions/setup-r@0ed4cdf40958ef43a6b33b9792e07ac76c3239e3 # v2.6.4 with: - r-version: '3.5.3' + r-version: '4.3.3' # Lint R files: - name: 'Lint R files' diff --git a/.github/workflows/namespace_exports.yml b/.github/workflows/namespace_exports.yml index 0ef90162b160..bc4fe0da079f 100644 --- a/.github/workflows/namespace_exports.yml +++ b/.github/workflows/namespace_exports.yml @@ -21,12 +21,6 @@ name: namespace_exports # Workflow triggers: on: - pull_request_target: - branches: - - develop - types: - - closed - # Allow the workflow to be manually run: workflow_dispatch: diff --git a/.github/workflows/run_affected_benchmarks.yml b/.github/workflows/run_affected_benchmarks.yml index 735f299a816c..677107bd5d52 100644 --- a/.github/workflows/run_affected_benchmarks.yml +++ b/.github/workflows/run_affected_benchmarks.yml @@ -119,3 +119,12 @@ jobs: make benchmark-javascript-files FILES="${files}" fi timeout-minutes: 30 + + # Run C benchmarks: + - name: 'Run C benchmarks' + run: | + files=$(echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n' | grep -E '\.c$' | sed "s|^|${GITHUB_WORKSPACE}/|" | tr '\n' ' ' | sed 's/ $//') + if [ -n "$files" ]; then + make benchmark-c-files FILES="${files}" + fi + timeout-minutes: 15 diff --git a/.github/workflows/scripts/run_affected_tests b/.github/workflows/scripts/run_affected_tests index 9932f836f002..cda0b7b342a1 100644 --- a/.github/workflows/scripts/run_affected_tests +++ b/.github/workflows/scripts/run_affected_tests @@ -145,7 +145,7 @@ main() { # Build native add-ons for packages (if applicable): for pkg in ${packages}; do - if [ -f "lib/node_modules/@stdlib/${pkg}/binding.gyp" ]; then + if [ -f "lib/node_modules/${pkg}/binding.gyp" ]; then NODE_ADDONS_PATTERN="${pkg}" make install-node-addons fi done diff --git a/.mailmap b/.mailmap index 6281d3d0495e..7b5a845ca611 100644 --- a/.mailmap +++ b/.mailmap @@ -8,9 +8,21 @@ # A +Adarsh Palaskar <83298237+adarshpalaskar1@users.noreply.github.com> +Adarsh Palaskar adarshpalaskar1 + +Aditya Sapra <110766802+adityacodes30@users.noreply.github.com> +Aditya Sapra adityacodes30 + +Aman Bhansali <92033532+aman-095@users.noreply.github.com> +Aman Bhansali aman-095 + Amit Jimiwal <90555965+amitjimiwal@users.noreply.github.com> Amit Jimiwal drunken_devv +Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> +Anudeep Sanapala anudeeps0306 + Athan Reines kgryte Athan Reines Athan @@ -18,6 +30,10 @@ Athan Reines Athan Bruno Fenzl +# C + +Chinmay Joshi <86140365+JawHawk@users.noreply.github.com> Chinmay J + # D Dorrin Sotoudeh <59933477+dorrin-sot@users.noreply.github.com> @@ -27,24 +43,39 @@ Dorrin Sotoudeh dorrin-sot Frank Kovacs +# G + +Golden Kumar <103646877+AuenKr@users.noreply.github.com> Golden +Golden Kumar <103646877+AuenKr@users.noreply.github.com> AuenKr + +Gunj Joshi GUNJ JOSHI + # H Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com> # J +Jaimin Godhani <112328542+Jai0401@users.noreply.github.com> Jai0401 + James Gelok James Jaysukh Makvana <111515433+Jaysukh-409@users.noreply.github.com> Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com> Jordan-Gallivan +# K + +Karthik Prakash <116057817+skoriop@users.noreply.github.com> skoriop + # M Marcus Fantham Marcus Matt Cochrane +Mihir Pandit <129577900+MSP20086@users.noreply.github.com> MSP20086 + # N Naresh Jagadeesan <37257700+Infinage@users.noreply.github.com> @@ -58,25 +89,65 @@ Philipp Burckhardt Planeshifter Pranav Goswami <85227306+Pranavchiku@users.noreply.github.com> Pranav Goswami Pranav +Praneki <97080887+PraneGIT@users.noreply.github.com> PraneGIT + +Pratik <97464067+Pratik772846@users.noreply.github.com> Pratik772846 + +Priyansh <88396544+itsspriyansh@users.noreply.github.com> itsspriyansh + # R +Raunak Kumar Gupta <95216822+raunak-dev-edu@users.noreply.github.com> +Raunak Kumar Gupta raunak-dev-edu + rei2hu +Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Rejoan-Sardar + Ricky Reusser Ricky Reusser <572717+rreusser@users.noreply.github.com> Robert Gislason rgizz +Rutam <138517416+performant23@users.noreply.github.com> performant23 + Ryan Seal Splrk # S +Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com> the-r3aper7 + +Shashank Shekhar Singh <123410790+Shashankss1205@users.noreply.github.com> +Shashank Shekhar Singh Shashankss1205 + +Shubham Mishra +Shubham Mishra shubham + +Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com> Snehil-Shah + +Spandan Barve <114365550+marsian83@users.noreply.github.com> +Spandan Barve marsian83 + stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Stephannie Jiménez Gacha Stephannie Jiménez Gacha Stephannie Jimenez Stephannie Jiménez Gacha Stephannie Jimenez Gacha +# U + +Utkarsh <137638507+Ut-the-pro@users.noreply.github.com> +Utkarsh Ut-the-pro + +Utkarsh Raj <49344502+rajutkarsh07@users.noreply.github.com> +Utkarsh Raj rajutkarsh07 +Utkarsh Raj utkarsh_raj + +# V + +Varad Gupta <114755221+vr-varad@users.noreply.github.com> +Varad Gupta vr-varad + # Y Yernar Yergaziyev diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b637fec9ecab..12e6f49663dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,7 +118,17 @@ Create a [GitHub account][github-signup]. The project uses GitHub exclusively fo $ git clone https://github.com//stdlib.git ``` -where `` is your GitHub username. The repository has a large commit history, leading to slow download times. You can reduce the download time by limiting the clone [depth][git-clone-depth]. +where `` is your GitHub username. When cloning, avoid cloning to a directory having spaces in its path. Because this project relies heavily on `make`, any spaces in the directory path will lead to errors and inevitable frustration. + +```text +// Bad: +/home/foo/bar/beep boop/stdlib + +// Good: +/home/foo/bar/beep_boop/stdlib +``` + +The repository has a large commit history, leading to slow download times. You can reduce the download time by limiting the clone [depth][git-clone-depth]. @@ -152,7 +162,27 @@ And finally, add an `upstream` [remote][git-remotes] to allow syncing changes be $ git remote add upstream git://github.com/stdlib-js/stdlib.git ``` -#### Step 2: Branch +#### Step 2: Initial Setup + +Install dependencies. + + + +```bash +$ make install +``` + +Initialize Git hooks to enable automated development processes to run prior to authoring commits and pushing changes. + + + +```bash +$ make init +``` + +Note that `make init` only needs to be run once; however, we repeat it below as **not** running it is a common omission by new contributors. + +#### Step 3: Branch For modifications intended to be included in stdlib, create a new local branch. @@ -164,11 +194,11 @@ $ git checkout -b where `` is the branch name. Both the `master` and `develop` branches for the main stdlib project are protected, and direct modifications to these branches will **not** be accepted. Instead, all contributions should be made on non-master and non-develop local branches, including documentation changes and other non-code modifications. See the project [branching guide][stdlib-branching] for additional guidance. -#### Step 3: Write +#### Step 4: Write Start making your changes and/or implementing the new feature. Any text you write should follow the [text style guide][stdlib-style-guides-text], including comments and API documentation. -#### Step 4: Commit +#### Step 5: Commit Ensure that you have configured [Git][git] to know your name and email address. @@ -190,7 +220,7 @@ $ git commit When writing commit messages, follow the Git [style guide][stdlib-style-guides-git]. Adherence to project commit conventions is necessary for project automation which automatically generates release notes and changelogs from commit messages. -#### Step 5: Sync +#### Step 6: Sync To incorporate recent changes from the `upstream` repository during development, you should [rebase][git-rebase] your local branch, reapplying your local commits on top of the current upstream `HEAD`. This procedure is in contrast to performing a standard [merge][git-merge], which may interleave development histories. The rationale is twofold: @@ -206,11 +236,13 @@ $ git fetch upstream $ git rebase upstream/develop ``` -#### Step 6: Test +#### Step 7: Test Tests should accompany **all** bug fixes and features. For guidance on how to write tests, consult existing tests within the project. -**Before** submitting a [pull request][github-pull-request] to the `upstream` repository, ensure that all tests pass, including linting. If [Git][git] hooks have been enabled, +**Before** submitting a [pull request][github-pull-request] to the `upstream` repository, ensure that all tests pass, including linting. To run tests locally, consult the guidance [below](#writing-tests). + +If [Git][git] hooks have been enabled, @@ -222,7 +254,7 @@ linting should be automatically triggered prior to each commit, and test executi Any [pull requests][github-pull-request] which include failing tests and/or lint errors will **not** be accepted. -#### Step 7: Push +#### Step 8: Push Push your changes to your remote GitHub repository. @@ -234,7 +266,7 @@ $ git push origin where `` is the name of your branch. -#### Step 8: Pull Request +#### Step 9: Pull Request Once your contribution is ready to be incorporated in the `upstream` repository, open a [pull request][github-pull-request] against the `develop` branch. One or more project contributors will review the contribution, provide feedback, and potentially request changes. @@ -280,13 +312,13 @@ $ git commit -m "fixup! feat: add support for computing the absolute value" If the history needs modification, a contributor will modify the history during the merge process. The rationale for **not** rewriting public history is that doing so invalidates the commit history for anyone else who has pulled your changes, thus imposing additional burdens on collaborators to ensure that their local versions match the modified history. -#### Step 9: Land +#### Step 10: Land After any changes have been resolved and continuous integration tests have passed, a contributor will approve a [pull request][github-pull-request] for inclusion in the project. Once merged, the [pull request][github-pull-request] will be updated with the merge commit, and the [pull request][github-pull-request] will be closed. Note that, during the merge process, multiple commits will often be [squashed][git-rewriting-history]. -#### Step 10: Celebrate +#### Step 11: Celebrate **Congratulations**! You are an official contributor to stdlib! Thank you for your hard work and patience! @@ -316,7 +348,7 @@ The project can **never** have enough tests. To address areas lacking sufficient ```bash - $ make TESTS_FILTER=.*//.* test + $ make TESTS_FILTER=".*//.*" test ``` where `` is a pattern matching a particular path. For example, to test the base math `sin` package @@ -324,7 +356,7 @@ The project can **never** have enough tests. To address areas lacking sufficient ```bash - $ make TESTS_FILTER=.*/math/base/special/sin/.* test + $ make TESTS_FILTER=".*/math/base/special/sin/.*" test ``` where the pattern `.*/math/base/special/sin/.*` matches any test file whose absolute path contains `math/base/special/sin`. @@ -334,7 +366,7 @@ The project can **never** have enough tests. To address areas lacking sufficient ```bash - $ make TESTS_FILTER=.*//.* test-cov + $ make TESTS_FILTER=".*//.*" test-cov $ make view-cov ``` @@ -342,6 +374,16 @@ The project can **never** have enough tests. To address areas lacking sufficient 7. Submit the test as a [pull request][github-pull-request]. +Note that, for contributions targeting C implementations, you'll need to first compile the native add-on which provides the bridge between JavaScript and C (assuming that the package has a native add-on binding). + +```bash +$ make install-node-addons NODE_ADDONS_PATTERN="math/base/special/sin" +``` + +where the pattern `math/base/special/sin` (note the differences from the filter pattern above!) matches any add-on whose absolute path contains `math/base/special/sin`. + +Once the add-on is compiled, you can follow steps 5-7 above. + ### Writing Documentation > By contributing documentation to the project, you are agreeing to release it under the project [license][stdlib-license]. diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0ad498e65985..80fabbb77aa8 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2,17 +2,18 @@ # # Contributors listed in alphabetical order. -Adarsh Palaskar <83298237+adarshpalaskar1@users.noreply.github.com> -Aditya Sapra <110766802+adityacodes30@users.noreply.github.com> +Adarsh Palaskar +Aditya Sapra AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com> Ali Salesi -Aman Bhansali <92033532+aman-095@users.noreply.github.com> +Aman Bhansali Amit Jimiwal -Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> +Anudeep Sanapala Athan Reines Brendan Graetz Bruno Fenzl -Chinmay J <86140365+JawHawk@users.noreply.github.com> +Bryan Elee +Chinmay Joshi <86140365+JawHawk@users.noreply.github.com> Christopher Dambamuromo Dan Rose Daniel Killenberger @@ -20,13 +21,14 @@ Dominik Moritz Dorrin Sotoudeh EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> Frank Kovacs -GUNJ JOSHI -Golden <103646877+AuenKr@users.noreply.github.com> +Golden Kumar <103646877+AuenKr@users.noreply.github.com> +Gunj Joshi Harshita Kalani Jaimin Godhani <112328542+Jai0401@users.noreply.github.com> James Gelok Jaysukh Makvana Jithin KS +Joel Mathew Koshy Joey Reed Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com> Joris Labie @@ -50,6 +52,7 @@ Pranav Goswami Praneki <97080887+PraneGIT@users.noreply.github.com> Pratik <97464067+Pratik772846@users.noreply.github.com> Priyansh <88396544+itsspriyansh@users.noreply.github.com> +Raunak Kumar Gupta Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Ricky Reusser Robert Gislason @@ -58,16 +61,16 @@ Rutam <138517416+performant23@users.noreply.github.com> Ryan Seal Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com> Seyyed Parsa Neshaei -Shashank Shekhar Singh <123410790+Shashankss1205@users.noreply.github.com> +Shashank Shekhar Singh Shraddheya Shendre -Shubham +Shubham Mishra Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com> -Spandan Barve <114365550+marsian83@users.noreply.github.com> +Spandan Barve Stephannie Jiménez Gacha -Utkarsh <137638507+Ut-the-pro@users.noreply.github.com> +Utkarsh +Utkarsh Raj +Varad Gupta Yernar Yergaziyev nishant-s7 <97207366+nishant-s7@users.noreply.github.com> orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu -utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> -vr-varad <114755221+vr-varad@users.noreply.github.com> diff --git a/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile b/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile index db82bdc9de80..f5ffcc57006e 100755 --- a/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile +++ b/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile @@ -108,6 +108,8 @@ function main( dir ) { if ( exists( join( pkgs[ i ], GYPFILES[ j ] ) ) ) { pkg.gypfile = true; break; + } else { + delete pkg.gypfile; } } diff --git a/lib/node_modules/@stdlib/array/base/README.md b/lib/node_modules/@stdlib/array/base/README.md index 91820a24b21d..a94717ce5560 100644 --- a/lib/node_modules/@stdlib/array/base/README.md +++ b/lib/node_modules/@stdlib/array/base/README.md @@ -89,6 +89,8 @@ The namespace exports the following: - [`copyIndexed( x )`][@stdlib/array/base/copy-indexed]: copy the elements of an indexed array-like object to a new "generic" array. - [`copy( x )`][@stdlib/array/base/copy]: copy the elements of an array-like object to a new "generic" array. - [`countFalsy( x )`][@stdlib/array/base/count-falsy]: count the number of falsy elements in an array. +- [`countSameValueZero( x, value )`][@stdlib/array/base/count-same-value-zero]: count the number of elements in an array that are equal to a specified value. +- [`countSameValue( x, value )`][@stdlib/array/base/count-same-value]: count the number of elements in an array that are equal to a specified value. - [`countTruthy( x )`][@stdlib/array/base/count-truthy]: count the number of truthy elements in an array. - [`dedupe( x, limit, equalNaNs )`][@stdlib/array/base/dedupe]: remove consecutive duplicated values. - [`everyByRight( x, predicate[, thisArg] )`][@stdlib/array/base/every-by-right]: test whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. @@ -337,6 +339,10 @@ console.log( objectKeys( ns ) ); [@stdlib/array/base/count-falsy]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-falsy +[@stdlib/array/base/count-same-value-zero]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-same-value-zero + +[@stdlib/array/base/count-same-value]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-same-value + [@stdlib/array/base/count-truthy]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-truthy [@stdlib/array/base/dedupe]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/dedupe diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md b/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md index cb75ff0c3283..5e68b041e2e5 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md @@ -20,7 +20,7 @@ limitations under the License. # countSameValueZero -> Count the number of elements that are equal to a given value in an array. +> Count the number of elements in an array that are equal to a specified value. @@ -42,7 +42,7 @@ var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); #### countSameValueZero( x, value ) -Counts the number of elements that are equal to a given value in an array. +Counts the number of elements in an array that are equal to a specified value. ```javascript var x = [ 0, 1, 0, 1, 2 ]; @@ -51,6 +51,24 @@ var out = countSameValueZero( x, 1 ); // returns 2 ``` +In contrast to an implementation using the strict equality operator `===`, the function treats `NaNs` as the same value. + +```javascript +var x = [ NaN, NaN, NaN ]; + +var out = countSameValueZero( x, NaN ); +// returns 3 +``` + +In contrast to an implementation using the [SameValue Algorithm][@stdlib/array/base/count-same-value] (as specified in ECMAScript 5), the function does not distinguish between `+0` and `-0`. + +```javascript +var x = [ 0.0, -0.0, 0.0 ]; + +var out = countSameValueZero( x, 0.0 ); +// returns 3 +``` + @@ -72,10 +90,12 @@ var out = countSameValueZero( x, 1 ); ```javascript -var sample = require( '@stdlib/random/sample' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); -var x = sample( [ 1, 2, 3, 4, 5 ] ); +var x = bernoulli( 10, 0.5, { + 'dtype': 'generic' +}); console.log( x ); var n = countSameValueZero( x, 1 ); @@ -106,6 +126,8 @@ console.log( n ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt index dd1d1fc13c78..f74b77f678a8 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt @@ -1,6 +1,9 @@ {{alias}}( x, value ) - Counts the number of elements that are equal to a given value in an array. + Counts the number of elements in an array that are equal to a specified + value. + + The function treats `NaN` values as the same value. Parameters ---------- @@ -13,7 +16,7 @@ Returns ------- out: integer - Number of elements that are equal to the given value. + Number of elements that are equal to a specified value. Examples -------- diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts index fdc419661b32..4ba495962164 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts @@ -23,11 +23,15 @@ import { Collection } from '@stdlib/types/array'; /** -* Counts the number of elements that are equal to a given value in an array. +* Counts the number of elements in an array that are equal to a specified value. +* +* ## Notes +* +* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value. * * @param x - input array -* @param value - given value -* @returns number of elements that are equal to the given value +* @param value - search value +* @returns number of elements that are equal to a specified value * * @example * var x = [ 0, 1, 0, 1, 1 ]; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/examples/index.js similarity index 82% rename from lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js rename to lib/node_modules/@stdlib/array/base/count-same-value-zero/examples/index.js index c85282e909e4..27e165dc27c0 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var sample = require( '@stdlib/random/sample' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); var countSameValueZero = require( './../lib' ); -var x; -var n; -x = sample( [ 1, 2, 3, 4, 5 ] ); +var x = bernoulli( 10, 0.5, { + 'dtype': 'generic' +}); console.log( x ); -n = countSameValueZero( x, 1 ); +var n = countSameValueZero( x, 1 ); console.log( n ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js index 75abf6a6044c..a115d7736b42 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Count the number of elements that are equal to a given value in an array. +* Count the number of elements in an array that are equal to a specified value. * * @module @stdlib/array/base/count-same-value-zero * diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js index da037d08e1c3..cdff888a7ae6 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js @@ -33,12 +33,12 @@ var isSameValueZero = require( '@stdlib/assert/is-same-value-zero' ); // FUNCTIONS // /** -* Counts the number of elements that are equal to a given value in an indexed array. +* Counts the number of elements in an indexed array that are equal to a specified value. * * @private * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example * var x = [ 0, 0, 1, 0, 1 ]; @@ -60,12 +60,12 @@ function indexed( x, value ) { } /** -* Counts the number of elements that are equal to a given value in an accessor array. +* Counts the number of elements in an accessor array that are equal to a specified value. * * @private * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); @@ -92,16 +92,16 @@ function accessors( x, value ) { } /** -* Counts the number of elements that are equal to a given value in a complex array. +* Counts the number of elements in a complex array that are equal to a specified value. * * @private * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example -* var Complex128 = require( '@stdlib/complex/float64' ); * var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); * * var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); * @@ -118,7 +118,6 @@ function complex( x, value ) { if ( !isComplexLike( value ) ) { return 0; } - re = real( value ); im = imag( value ); @@ -126,10 +125,7 @@ function complex( x, value ) { n = 0; for ( i = 0; i < view.length; i += 2 ) { - if ( - isSameValueZero( view[ i ], re ) && - isSameValueZero( view[ i + 1 ], im ) - ) { + if ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i+1 ], im ) ) { // eslint-disable-line max-len n += 1; } } @@ -140,11 +136,16 @@ function complex( x, value ) { // MAIN // /** -* Counts the number of elements that are equal to a given value in an array. +* Counts the number of elements in an array that are equal to a specified value. +* +* ## Notes +* +* - The function uses the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016. +* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value. * * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example * var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json b/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json index 130c9f6c734d..7ac01393e98b 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/array/base/count-same-value-zero", "version": "0.0.0", - "description": "Count the number of elements that are equal to a given value in an array.", + "description": "Count the number of elements in an array that are equal to a specified value.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -17,6 +17,7 @@ "directories": { "benchmark": "./benchmark", "doc": "./docs", + "example": "./examples", "lib": "./lib", "test": "./test" }, @@ -59,6 +60,7 @@ "summation", "countif", "total", - "same" + "same", + "equal" ] } diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js index 65327a5b4a41..6fb5820d0592 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js @@ -45,11 +45,12 @@ tape( 'the function counts the number of same values (generic)', function test( x = [ 0, 1, 0, 1, 2 ]; expected = 2; actual = countSameValueZero( x, 1 ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); -tape( 'the function consider positive and negative zeros to be indentical (generic)', function test( t ) { +tape( 'the function considers positive and negative zeros to be identical (generic)', function test( t ) { var expected; var actual; var x; @@ -67,7 +68,7 @@ tape( 'the function considers all NaN values to be identical (generic)', functio var actual; var x; - x = [ NaN, 0, NaN, 2, NaN, 9, NaN ]; + x = [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ]; expected = 4; actual = countSameValueZero( x, NaN ); @@ -87,7 +88,7 @@ tape( 'the function counts the number of same values (accessors)', function test t.end(); }); -tape( 'the function consider positive and negative zeros to be indentical (accessors)', function test( t ) { +tape( 'the function considers positive and negative zeros to be identical (accessors)', function test( t ) { var expected; var actual; var x; @@ -105,7 +106,7 @@ tape( 'the function considers all NaN values to be identical (accessors)', funct var actual; var x; - x = toAccessorArray( [ NaN, 0, NaN, 2, NaN, 9, NaN ] ); + x = toAccessorArray( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); expected = 4; actual = countSameValueZero( x, NaN ); @@ -126,7 +127,7 @@ tape( 'the function counts the number of same values (real typed array)', functi t.end(); }); -tape( 'the function consider positive and negative zeros to be indentical (real typed array)', function test( t ) { +tape( 'the function considers positive and negative zeros to be identical (real typed array)', function test( t ) { var expected; var actual; var x; @@ -144,7 +145,7 @@ tape( 'the function considers all NaN values to be identical (real typed array)' var actual; var x; - x = new Float32Array( [ NaN, 0, NaN, 2, NaN, 9, NaN ] ); + x = new Float32Array( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); expected = 4; actual = countSameValueZero( x, NaN ); @@ -160,16 +161,23 @@ tape( 'the function counts the number of same values (complex typed array)', fun x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); expected = 1; actual = countSameValueZero( x, new Complex128( 3.0, 4.0 ) ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); + expected = 0; + actual = countSameValueZero( x, 0.0 ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); -tape( 'the function consider positive and negative zeros to be indentical (complex typed array)', function test( t ) { +tape( 'the function considers positive and negative zeros to be identical (complex typed array)', function test( t ) { var expected; var actual; var x; - x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); + x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); // eslint-disable-line max-len expected = 5; actual = countSameValueZero( x, new Complex128( 0.0, -0.0 ) ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/README.md b/lib/node_modules/@stdlib/array/base/count-same-value/README.md index 92b701e2cae4..9fea78d76138 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/README.md +++ b/lib/node_modules/@stdlib/array/base/count-same-value/README.md @@ -20,7 +20,7 @@ limitations under the License. # countSameValue -> Count the number of elements that are equal to a given value in an array. +> Count the number of elements in an array that are equal to a specified value. @@ -42,7 +42,7 @@ var countSameValue = require( '@stdlib/array/base/count-same-value' ); #### countSameValue( x, value ) -Counts the number of elements that are equal to a given value in an array. +Counts the number of elements in an array that are equal to a specified value. ```javascript var x = [ 0, 1, 0, 1, 2 ]; @@ -51,6 +51,15 @@ var out = countSameValue( x, 1 ); // returns 2 ``` +In contrast to an implementation using the strict equality operator `===`, the function distinguishes between `+0` and `-0` and treats `NaNs` as the same value. + +```javascript +var x = [ NaN, NaN, NaN ]; + +var out = countSameValue( x, NaN ); +// returns 3 +``` + @@ -59,6 +68,10 @@ var out = countSameValue( x, 1 );
+## Notes + +- The function uses the [SameValue Algorithm][@stdlib/assert/is-same-value] as specified in ECMAScript 5. +
@@ -72,10 +85,12 @@ var out = countSameValue( x, 1 ); ```javascript -var sample = require( '@stdlib/random/sample' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); var countSameValue = require( '@stdlib/array/base/count-same-value' ); -var x = sample( [ 1, 2, 3, 4, 5 ] ); +var x = bernoulli( 10, 0.5, { + 'dtype': 'generic' +}); console.log( x ); var n = countSameValue( x, 1 ); @@ -106,6 +121,8 @@ console.log( n ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-same-value/docs/repl.txt index dd1d1fc13c78..5fdd65f6dfa3 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/base/count-same-value/docs/repl.txt @@ -1,6 +1,9 @@ {{alias}}( x, value ) - Counts the number of elements that are equal to a given value in an array. + Counts the number of elements in an array that are equal to a specified + value. + + The function treats `-0` and `+0` as distinct and `NaNs` as the same. Parameters ---------- @@ -13,7 +16,7 @@ Returns ------- out: integer - Number of elements that are equal to the given value. + Number of elements that are equal to the specified value. Examples -------- diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-same-value/docs/types/index.d.ts index 3a656bd87735..24ccc5ab2957 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/count-same-value/docs/types/index.d.ts @@ -23,11 +23,18 @@ import { Collection } from '@stdlib/types/array'; /** -* Counts the number of elements that are equal to a given value in an array. +* Counts the number of elements in an array that are equal to a specified value. +* +* ## Notes +* +* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. +* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. +* +* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 * * @param x - input array -* @param value - given value -* @returns number of elements that are equal to the given value +* @param value - search value +* @returns number of elements that are equal to a specified value * * @example * var x = [ 0, 1, 0, 1, 1 ]; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/examples/index.js b/lib/node_modules/@stdlib/array/base/count-same-value/examples/index.js index f76a9ff3642c..7306f2b034c8 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/examples/index.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value/examples/index.js @@ -18,10 +18,12 @@ 'use strict'; -var sample = require( '@stdlib/random/sample' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); var countSameValue = require( './../lib' ); -var x = sample( [ 1, 2, 3, 4, 5 ] ); +var x = bernoulli( 10, 0.5, { + 'dtype': 'generic' +}); console.log( x ); var n = countSameValue( x, 1 ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/lib/index.js b/lib/node_modules/@stdlib/array/base/count-same-value/lib/index.js index bccf8d32d85f..9e28a14dde75 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/lib/index.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Count the number of elements that are equal to a given value in an array. +* Count the number of elements in an array that are equal to a specified value. * * @module @stdlib/array/base/count-same-value * diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value/lib/main.js index 72de05892f6a..685cd1ef7c03 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value/lib/main.js @@ -21,30 +21,30 @@ // MODULES // var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var real = require( '@stdlib/complex/real' ); -var imag = require( '@stdlib/complex/imag' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); var isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' ); var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); var isSameValue = require( '@stdlib/assert/is-same-value' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); // FUNCTIONS // /** -* Counts the number of elements that are equal to a given value in an indexed array. +* Counts the number of elements in an array that are equal to a specified value. * * @private * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example -* var x = [ 0, 1, 0, 1 ]; +* var x = [ 0, 1, 0, 1, 1 ]; * * var n = indexed( x, 1 ); -* // returns 2 +* // returns 3 */ function indexed( x, value ) { var n; @@ -60,20 +60,20 @@ function indexed( x, value ) { } /** -* Counts the number of elements that are equal to a given value in an accessor array. +* Counts the number of elements in an accessor array that are equal to a specified value. * * @private * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a provided value * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * -* var x = toAccessorArray( [ 0, 1, 0, 1 ] ); +* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); * * var n = accessors( x, 1 ); -* // returns 2 +* // returns 3 */ function accessors( x, value ) { var get; @@ -92,16 +92,16 @@ function accessors( x, value ) { } /** -* Counts the number of elements that are equal to a given value in a complex array. +* Counts the number of elements in a complex array that are equal to a specified value. * * @private * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example -* var Complex128 = require( '@stdlib/complex/float64' ); * var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); * * var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); * @@ -118,7 +118,6 @@ function complex( x, value ) { if ( !isComplexLike( value ) ) { return 0; } - re = real( value ); im = imag( value ); @@ -126,7 +125,7 @@ function complex( x, value ) { n = 0; for ( i = 0; i < view.length; i += 2 ) { - if ( isSameValue( view[ i ], re ) && isSameValue( view[ i + 1 ], im ) ) { + if ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) { n += 1; } } @@ -137,11 +136,18 @@ function complex( x, value ) { // MAIN // /** -* Counts the number of elements that are equal to a given value in an array. +* Counts the number of elements in an array that are equal to a specified value. +* +* ## Notes +* +* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. +* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. +* +* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 * * @param {Collection} x - input array -* @param {*} value - given value -* @returns {NonNegativeInteger} number of elements that are equal to the given value +* @param {*} value - search value +* @returns {NonNegativeInteger} number of elements that are equal to a specified value * * @example * var x = [ 0, 1, 0, 1, 1 ]; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/package.json b/lib/node_modules/@stdlib/array/base/count-same-value/package.json index 17a9abe39c3e..731e0336c439 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/package.json +++ b/lib/node_modules/@stdlib/array/base/count-same-value/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/array/base/count-same-value", "version": "0.0.0", - "description": "Count the number of elements that are equal to a given value in an array.", + "description": "Count the number of elements in an array that are equal to a specified value.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -60,6 +60,7 @@ "summation", "countif", "total", - "same" + "same", + "equal" ] } diff --git a/lib/node_modules/@stdlib/array/base/count-same-value/test/test.js b/lib/node_modules/@stdlib/array/base/count-same-value/test/test.js index 0d56293b2337..12fd47acd869 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value/test/test.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value/test/test.js @@ -56,10 +56,15 @@ tape( 'the function distinguishes between positive and negative zeros (generic)' var x; x = [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ]; + expected = 3; actual = countSameValue( x, 0.0 ); + t.strictEqual( actual, expected, 'returns expected value' ); + expected = 2; + actual = countSameValue( x, -0.0 ); t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); }); @@ -68,7 +73,7 @@ tape( 'the function considers all NaN values to be identical (generic)', functio var actual; var x; - x = [ NaN, 0, NaN, 2, NaN, 9, NaN ]; + x = [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ]; expected = 4; actual = countSameValue( x, NaN ); @@ -95,10 +100,15 @@ tape( 'the function distinguishes between positive and negative zeros (accessors var x; x = toAccessorArray( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); + expected = 3; actual = countSameValue( x, 0.0 ); + t.strictEqual( actual, expected, 'returns expected value' ); + expected = 2; + actual = countSameValue( x, -0.0 ); t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); }); @@ -107,7 +117,7 @@ tape( 'the function considers all NaN values to be identical (accessors)', funct var actual; var x; - x = toAccessorArray( [ NaN, 0, NaN, 2, NaN, 9, NaN ] ); + x = toAccessorArray( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); expected = 4; actual = countSameValue( x, NaN ); @@ -134,10 +144,15 @@ tape( 'the function distinguishes between positive and negative zeros (real type var x; x = new Float32Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); + expected = 3; actual = countSameValue( x, 0.0 ); + t.strictEqual( actual, expected, 'returns expected value' ); + expected = 2; + actual = countSameValue( x, -0.0 ); t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); }); @@ -146,7 +161,7 @@ tape( 'the function considers all NaN values to be identical (real typed array)' var actual; var x; - x = new Float32Array( [ NaN, 0, NaN, 2, NaN, 9, NaN ] ); + x = new Float32Array( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); expected = 4; actual = countSameValue( x, NaN ); @@ -163,6 +178,12 @@ tape( 'the function counts the number of same values (complex typed array)', fun expected = 1; actual = countSameValue( x, new Complex128( 3.0, 4.0 ) ); + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); + expected = 0; + actual = countSameValue( x, 0.0 ); + t.strictEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -172,7 +193,7 @@ tape( 'the function distinguishes between positive and negative zeros (complex t var actual; var x; - x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); + x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); // eslint-disable-line max-len expected = 2; actual = countSameValue( x, new Complex128( 0.0, -0.0 ) ); diff --git a/lib/node_modules/@stdlib/array/base/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/docs/types/index.d.ts index b5ad9be9f8a0..fc6058e1fcac 100644 --- a/lib/node_modules/@stdlib/array/base/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/docs/types/index.d.ts @@ -64,6 +64,8 @@ import cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); import copy = require( '@stdlib/array/base/copy' ); import copyIndexed = require( '@stdlib/array/base/copy-indexed' ); import countFalsy = require( '@stdlib/array/base/count-falsy' ); +import countSameValue = require( '@stdlib/array/base/count-same-value' ); +import countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); import countTruthy = require( '@stdlib/array/base/count-truthy' ); import dedupe = require( '@stdlib/array/base/dedupe' ); import every = require( '@stdlib/array/base/every' ); @@ -1340,6 +1342,47 @@ interface Namespace { */ countFalsy: typeof countFalsy; + /** + * Counts the number of elements in an array that are equal to a specified value. + * + * ## Notes + * + * - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. + * - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. + * + * [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 + * + * @param x - input array + * @param value - search value + * @returns number of elements that are equal to a specified value + * + * @example + * var x = [ 0, 1, 0, 1, 1 ]; + * + * var out = ns.countSameValue( x, 1 ); + * // returns 3 + */ + countSameValue: typeof countSameValue; + + /** + * Counts the number of elements in an array that are equal to a specified value. + * + * ## Notes + * + * - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value. + * + * @param x - input array + * @param value - search value + * @returns number of elements that are equal to a specified value + * + * @example + * var x = [ 0, 1, 0, 1, 1 ]; + * + * var out = ns.countSameValueZero( x, 1 ); + * // returns 3 + */ + countSameValueZero: typeof countSameValueZero; + /** * Counts the number of truthy values in an array. * diff --git a/lib/node_modules/@stdlib/array/base/lib/index.js b/lib/node_modules/@stdlib/array/base/lib/index.js index 118a547c2af6..6c87e6ee14be 100644 --- a/lib/node_modules/@stdlib/array/base/lib/index.js +++ b/lib/node_modules/@stdlib/array/base/lib/index.js @@ -432,6 +432,24 @@ setReadOnly( ns, 'copyIndexed', require( '@stdlib/array/base/copy-indexed' ) ); */ setReadOnly( ns, 'countFalsy', require( '@stdlib/array/base/count-falsy' ) ); +/** +* @name countSameValue +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/array/base/count-same-value} +*/ +setReadOnly( ns, 'countSameValue', require( '@stdlib/array/base/count-same-value' ) ); + +/** +* @name countSameValueZero +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/array/base/count-same-value-zero} +*/ +setReadOnly( ns, 'countSameValueZero', require( '@stdlib/array/base/count-same-value-zero' ) ); + /** * @name countTruthy * @memberof ns diff --git a/lib/node_modules/@stdlib/array/mskreject/README.md b/lib/node_modules/@stdlib/array/mskreject/README.md index cbafb6172f73..2a7565e534ac 100644 --- a/lib/node_modules/@stdlib/array/mskreject/README.md +++ b/lib/node_modules/@stdlib/array/mskreject/README.md @@ -95,6 +95,12 @@ console.log( y ); @@ -105,6 +111,12 @@ console.log( y ); [@stdlib/array/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dtypes + + +[@stdlib/array/mskfilter]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/mskfilter + + + diff --git a/lib/node_modules/@stdlib/array/safe-casts/README.md b/lib/node_modules/@stdlib/array/safe-casts/README.md index 04ef1662bce4..4a6363e934b5 100644 --- a/lib/node_modules/@stdlib/array/safe-casts/README.md +++ b/lib/node_modules/@stdlib/array/safe-casts/README.md @@ -128,6 +128,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { - [`@stdlib/array/convert`][@stdlib/array/convert]: convert an array to an array of a different data type. - [`@stdlib/array/convert-same`][@stdlib/array/convert-same]: convert an array to the same data type as a second input array. - [`@stdlib/array/dtypes`][@stdlib/array/dtypes]: list of array data types. +- [`@stdlib/array/mostly-safe-casts`][@stdlib/array/mostly-safe-casts]: return a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast. - [`@stdlib/array/same-kind-casts`][@stdlib/array/same-kind-casts]: return a list of array data types to which a provided array data type can be safely cast or cast within the same kind. - [`@stdlib/ndarray/safe-casts`][@stdlib/ndarray/safe-casts]: return a list of ndarray data types to which a provided ndarray data type can be safely cast. @@ -147,6 +148,8 @@ for ( i = 0; i < DTYPES.length; i++ ) { [@stdlib/array/convert-same]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/convert-same +[@stdlib/array/mostly-safe-casts]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/mostly-safe-casts + [@stdlib/array/same-kind-casts]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/same-kind-casts [@stdlib/ndarray/safe-casts]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/safe-casts diff --git a/lib/node_modules/@stdlib/array/slice/README.md b/lib/node_modules/@stdlib/array/slice/README.md index b2ae6bb2c5ed..bd5dde0c88e6 100644 --- a/lib/node_modules/@stdlib/array/slice/README.md +++ b/lib/node_modules/@stdlib/array/slice/README.md @@ -145,6 +145,12 @@ s = slice( x, 2, 4 ); @@ -153,6 +159,12 @@ s = slice( x, 2, 4 ); diff --git a/lib/node_modules/@stdlib/assert/README.md b/lib/node_modules/@stdlib/assert/README.md index 78e679283ef2..906aaea12a3f 100644 --- a/lib/node_modules/@stdlib/assert/README.md +++ b/lib/node_modules/@stdlib/assert/README.md @@ -442,6 +442,7 @@ The remaining namespace utilities are as follows: - [`isNonConfigurableProperty( value, property )`][@stdlib/assert/is-nonconfigurable-property]: test if an object's own property is non-configurable. - [`isNonEnumerablePropertyIn( value, property )`][@stdlib/assert/is-nonenumerable-property-in]: test if an object's own or inherited property is non-enumerable. - [`isNonEnumerableProperty( value, property )`][@stdlib/assert/is-nonenumerable-property]: test if an object's own property is non-enumerable. +- [`isNonNegativeFinite( value )`][@stdlib/assert/is-nonnegative-finite]: test if a value is a number having a nonnegative finite value. - [`isObjectLike( value )`][@stdlib/assert/is-object-like]: test if a value is object-like. - [`isOdd( value )`][@stdlib/assert/is-odd]: test if a value is an odd number. - [`isPascalcase( value )`][@stdlib/assert/is-pascalcase]: test if a value is a string in Pascal case. @@ -686,6 +687,8 @@ console.log( objectKeys( assert ) ); [@stdlib/assert/is-nonenumerable-property]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-nonenumerable-property +[@stdlib/assert/is-nonnegative-finite]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-nonnegative-finite + [@stdlib/assert/is-object-like]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-object-like [@stdlib/assert/is-odd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-odd diff --git a/lib/node_modules/@stdlib/assert/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/docs/types/index.d.ts index 58f61e58a7b5..dbc1fc4f0926 100644 --- a/lib/node_modules/@stdlib/assert/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/docs/types/index.d.ts @@ -206,6 +206,7 @@ import isNonConfigurableProperty = require( '@stdlib/assert/is-nonconfigurable-p import isNonConfigurablePropertyIn = require( '@stdlib/assert/is-nonconfigurable-property-in' ); import isNonEnumerableProperty = require( '@stdlib/assert/is-nonenumerable-property' ); import isNonEnumerablePropertyIn = require( '@stdlib/assert/is-nonenumerable-property-in' ); +import isNonNegativeFinite = require( '@stdlib/assert/is-nonnegative-finite' ); import isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ); import isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ); import isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); @@ -4336,6 +4337,8 @@ interface Namespace { */ isNonEnumerablePropertyIn: typeof isNonEnumerablePropertyIn; + isNonNegativeFinite: typeof isNonNegativeFinite; + /** * Tests if a value is a nonnegative integer. * diff --git a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/benchmark/benchmark.js index 4e146b6c08a5..fffc22248bfc 100644 --- a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/benchmark/benchmark.js @@ -33,16 +33,39 @@ var isNonNegativeFinite = require( './../lib' ); // MAIN // -bench( pkg+'::primitives', function benchmark( b ) { +bench( pkg+'::true,primitives', function benchmark( b ) { var values; var bool; var i; values = [ - '5', 5.0, 4.0, - 3.14, + 3.14 + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isNonNegativeFinite( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::false,primitives', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + '5', -5.0, -4.0, NaN, @@ -69,7 +92,32 @@ bench( pkg+'::primitives', function benchmark( b ) { b.end(); }); -bench( pkg+'::objects', function benchmark( b ) { +bench( pkg+'::true,objects', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Number( 2.0 ), + new Number( 3.14 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isNonNegativeFinite( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::false,objects', function benchmark( b ) { var values; var bool; var i; @@ -78,9 +126,7 @@ bench( pkg+'::objects', function benchmark( b ) { [], {}, function noop() {}, - new Number( 2.0 ), - new Number( -3.0 ), - new Number( 3.14 ) + new Number( -3.0 ) ]; b.tic(); @@ -98,16 +144,39 @@ bench( pkg+'::objects', function benchmark( b ) { b.end(); }); -bench( pkg+'::primitives:isPrimitive', function benchmark( b ) { +bench( pkg+'::true,primitives:isPrimitive', function benchmark( b ) { var values; var bool; var i; values = [ - '5', 5.0, 4.0, - 3.14, + 3.14 + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isNonNegativeFinite.isPrimitive( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::false,primitives:isPrimitive', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + '5', -5.0, -4.0, NaN, @@ -134,7 +203,7 @@ bench( pkg+'::primitives:isPrimitive', function benchmark( b ) { b.end(); }); -bench( pkg+'::objects:isPrimitive', function benchmark( b ) { +bench( pkg+'::false,objects:isPrimitive', function benchmark( b ) { var values; var bool; var i; @@ -144,8 +213,8 @@ bench( pkg+'::objects:isPrimitive', function benchmark( b ) { {}, function noop() {}, new Number( 2.0 ), - new Number( -3.0 ), - new Number( 3.14 ) + new Number( 3.14 ), + new Number( -3.0 ) ]; b.tic(); @@ -163,7 +232,7 @@ bench( pkg+'::objects:isPrimitive', function benchmark( b ) { b.end(); }); -bench( pkg+'::primitives:isObject', function benchmark( b ) { +bench( pkg+'::false,primitives:isObject', function benchmark( b ) { var values; var bool; var i; @@ -199,7 +268,32 @@ bench( pkg+'::primitives:isObject', function benchmark( b ) { b.end(); }); -bench( pkg+'::objects:isObject', function benchmark( b ) { +bench( pkg+'::true,objects:isObject', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Number( 2.0 ), + new Number( 3.14 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isNonNegativeFinite.isObject( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::false,objects:isObject', function benchmark( b ) { var values; var bool; var i; @@ -208,9 +302,7 @@ bench( pkg+'::objects:isObject', function benchmark( b ) { [], {}, function noop() {}, - new Number( 2.0 ), new Number( -3.0 ), - new Number( 3.14 ), new Number( PINF ) ]; diff --git a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/repl.txt index 20cef1007620..a9c310760bd8 100644 --- a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/repl.txt @@ -16,7 +16,7 @@ -------- > var bool = {{alias}}( 5.0 ) true - > bool = {{alias}}( new Number( 5.0 ) ) + > bool = {{alias}}( new {{alias:@stdlib/number/ctor}}( 5.0 ) ) true > bool = {{alias}}( 3.14 ) true @@ -46,7 +46,7 @@ -------- > var bool = {{alias}}.isPrimitive( 3.0 ) true - > bool = {{alias}}.isPrimitive( new Number( 3.0 ) ) + > bool = {{alias}}.isPrimitive( new {{alias:@stdlib/number/ctor}}( 3.0 ) ) false @@ -68,7 +68,7 @@ -------- > var bool = {{alias}}.isObject( 3.0 ) false - > bool = {{alias}}.isObject( new Number( 3.0 ) ) + > bool = {{alias}}.isObject( new {{alias:@stdlib/number/ctor}}( 3.0 ) ) true diff --git a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/types/test.ts index 22b808241a5c..e5b6c039ee4f 100644 --- a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/docs/types/test.ts @@ -33,27 +33,27 @@ import isNonNegativeFinite = require( './index' ); isNonNegativeFinite( 2, 123 ); // $ExpectError } -// Attached to main export is an isPrimitive method which returns a boolean... +// Attached to main export is an `isPrimitive` method which returns a boolean... { // eslint-disable-next-line no-new-wrappers isNonNegativeFinite.isPrimitive( new Number( 2 ) ); // $ExpectType boolean isNonNegativeFinite.isPrimitive( 2 ); // $ExpectType boolean } -// The compiler throws an error if the isPrimitive method is provided an unsupported number of arguments... +// The compiler throws an error if the `isPrimitive` method is provided an unsupported number of arguments... { isNonNegativeFinite.isPrimitive(); // $ExpectError isNonNegativeFinite.isPrimitive( 2, 123 ); // $ExpectError } -// Attached to main export is an isObject method which returns a boolean... +// Attached to main export is an `isObject` method which returns a boolean... { // eslint-disable-next-line no-new-wrappers isNonNegativeFinite.isObject( new Number( 2 ) ); // $ExpectType boolean isNonNegativeFinite.isObject( 2 ); // $ExpectType boolean } -// The compiler throws an error if the isObject method is provided an unsupported number of arguments... +// The compiler throws an error if the `isObject` method is provided an unsupported number of arguments... { isNonNegativeFinite.isObject(); // $ExpectError isNonNegativeFinite.isObject( 2, 123 ); // $ExpectError diff --git a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.main.js b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.main.js index 3b331d86ea9b..c21a7292c5d6 100644 --- a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.main.js +++ b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.main.js @@ -33,9 +33,9 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns `true` if provided a number having a nonnegative number value', function test( t ) { - t.equal( isNonNegativeFinite( 5.0 ), true, 'returns true' ); - t.equal( isNonNegativeFinite( new Number( 5.0 ) ), true, 'returns true' ); +tape( 'the function returns `true` if provided a number having a nonnegative finite value', function test( t ) { + t.equal( isNonNegativeFinite( 5.0 ), true, 'returns expected value' ); + t.equal( isNonNegativeFinite( new Number( 5.0 ) ), true, 'returns expected value' ); t.end(); }); @@ -58,7 +58,7 @@ tape( 'the function returns `false` if not provided a number having a nonnegativ ]; for ( i = 0; i < values.length; i++ ) { - t.equal( isNonNegativeFinite( values[i] ), false, 'returns false when provided '+values[i] ); + t.equal( isNonNegativeFinite( values[i] ), false, 'returns expected value when provided '+values[i] ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.object.js b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.object.js index 04634f55c59f..4e629c33242d 100644 --- a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.object.js +++ b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.object.js @@ -33,18 +33,18 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns `true` if provided a number object having a nonnegative number value', function test( t ) { - t.equal( isNonNegativeFinite( new Number( 5.0 ) ), true, 'returns true' ); +tape( 'the function returns `true` if provided a number object having a nonnegative finite value', function test( t ) { + t.equal( isNonNegativeFinite( new Number( 5.0 ) ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns `false` if provided positive infinity', function test( t ) { - t.equal( isNonNegativeFinite( 1.0/0.0 ), false, 'returns false' ); +tape( 'the function returns `false` if provided positive infinity (primitive)', function test( t ) { + t.equal( isNonNegativeFinite( 1.0/0.0 ), false, 'returns expected value' ); t.end(); }); -tape( 'the function returns `false` if provided positive infinity', function test( t ) { - t.equal( isNonNegativeFinite( new Number( 1.0/0.0 ) ), false, 'returns false' ); +tape( 'the function returns `false` if provided positive infinity (object)', function test( t ) { + t.equal( isNonNegativeFinite( new Number( 1.0/0.0 ) ), false, 'returns expected value' ); t.end(); }); @@ -68,7 +68,7 @@ tape( 'the function returns `false` if not provided a nonnegative number', funct ]; for ( i = 0; i < values.length; i++ ) { - t.equal( isNonNegativeFinite( values[i] ), false, 'returns false when provided '+values[i] ); + t.equal( isNonNegativeFinite( values[i] ), false, 'returns expected value when provided '+values[i] ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.primitive.js b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.primitive.js index c591b193225b..033d352c1444 100644 --- a/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.primitive.js +++ b/lib/node_modules/@stdlib/assert/is-nonnegative-finite/test/test.primitive.js @@ -34,22 +34,22 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function returns `true` if provided a primitive number having a nonnegative finite value', function test( t ) { - t.equal( isNonNegativeFinite( 3.0 ), true, 'returns true' ); + t.equal( isNonNegativeFinite( 3.0 ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `false` if provided a number object, even if the number has a nonnegative finite value', function test( t ) { - t.equal( isNonNegativeFinite( new Number( 5.0 ) ), false, 'returns false' ); + t.equal( isNonNegativeFinite( new Number( 5.0 ) ), false, 'returns expected value' ); t.end(); }); -tape( 'the function returns `false` if provided positive infinity', function test( t ) { - t.equal( isNonNegativeFinite( 1.0/0.0 ), false, 'returns false' ); +tape( 'the function returns `false` if provided positive infinity (primitive)', function test( t ) { + t.equal( isNonNegativeFinite( 1.0/0.0 ), false, 'returns expected value' ); t.end(); }); -tape( 'the function returns `false` if provided a number object with positive infinity', function test( t ) { - t.equal( isNonNegativeFinite( new Number( 1.0/0.0 ) ), false, 'returns false' ); +tape( 'the function returns `false` if provided positive infinity (object)', function test( t ) { + t.equal( isNonNegativeFinite( new Number( 1.0/0.0 ) ), false, 'returns expected value' ); t.end(); }); @@ -70,7 +70,7 @@ tape( 'the function returns `false` if not provided a nonnegative finite number' ]; for ( i = 0; i < values.length; i++ ) { - t.equal( isNonNegativeFinite( values[i] ), false, 'returns false when provided '+values[i] ); + t.equal( isNonNegativeFinite( values[i] ), false, 'returns expected value when provided '+values[i] ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 8690646d6bc5..b108d78075a9 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1710,6 +1710,15 @@ setReadOnly( ns, 'isNonEnumerableProperty', require( '@stdlib/assert/is-nonenume */ setReadOnly( ns, 'isNonEnumerablePropertyIn', require( '@stdlib/assert/is-nonenumerable-property-in' ) ); +/** +* @name isNonNegativeFinite +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-nonnegative-finite} +*/ +setReadOnly( ns, 'isNonNegativeFinite', require( '@stdlib/assert/is-nonnegative-finite' ) ); + /** * @name isNonNegativeInteger * @memberof ns diff --git a/lib/node_modules/@stdlib/blas/base/ddot/src/ddot.c b/lib/node_modules/@stdlib/blas/base/ddot/src/ddot.c index f8158a9f5a1e..ce2e3f491916 100644 --- a/lib/node_modules/@stdlib/blas/base/ddot/src/ddot.c +++ b/lib/node_modules/@stdlib/blas/base/ddot/src/ddot.c @@ -31,7 +31,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ double c_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_cblas.c b/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_cblas.c index 361c568c9c74..f4102a94bae4 100644 --- a/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_cblas.c @@ -27,7 +27,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ double c_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY ) { return cblas_ddot( N, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_f.c b/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_f.c index 5164387844b0..a9fbcd251f11 100644 --- a/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_f.c +++ b/lib/node_modules/@stdlib/blas/base/ddot/src/ddot_f.c @@ -32,7 +32,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ double c_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot.c b/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot.c index d931405d0e5d..21b1117e8fa1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot.c +++ b/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot.c @@ -31,7 +31,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_cblas.c b/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_cblas.c index f12e8fa985f0..31cda7eaa7e8 100644 --- a/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_cblas.c @@ -27,7 +27,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { return cblas_dsdot( N, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_f.c b/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_f.c index e8e3c7db1fba..1c06f1645a51 100644 --- a/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_f.c +++ b/lib/node_modules/@stdlib/blas/base/dsdot/src/dsdot_f.c @@ -32,7 +32,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdot/src/sdot.c b/lib/node_modules/@stdlib/blas/base/sdot/src/sdot.c index e983ccf1f7d0..8ed48cfb8c07 100644 --- a/lib/node_modules/@stdlib/blas/base/sdot/src/sdot.c +++ b/lib/node_modules/@stdlib/blas/base/sdot/src/sdot.c @@ -31,7 +31,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ float c_sdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_cblas.c b/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_cblas.c index 94080105ada1..a725236c56c3 100644 --- a/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_cblas.c @@ -27,7 +27,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ float c_sdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { return cblas_sdot( N, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_f.c b/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_f.c index 34997c6e4c89..743baf7d52b8 100644 --- a/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_f.c +++ b/lib/node_modules/@stdlib/blas/base/sdot/src/sdot_f.c @@ -34,7 +34,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product +* @return the dot product */ float c_sdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c index b9a1ea335e0c..ba3d601c02d5 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c @@ -32,7 +32,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns dot product +* @return dot product */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c index 99da4d35fde2..bd47331e1331 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c @@ -28,7 +28,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns dot product +* @return dot product */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { return cblas_sdsdot( N, scalar, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c index 1b2dfeb84274..8e5de1ca0cde 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c @@ -35,7 +35,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns dot product +* @return dot product */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/README.md b/lib/node_modules/@stdlib/blas/ext/base/dapx/README.md index 3449170450a5..1aadc282dbc5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/README.md @@ -32,7 +32,7 @@ var dapx = require( '@stdlib/blas/ext/base/dapx' ); #### dapx( N, alpha, x, stride ) -Adds a constant `alpha` to each element in a double-precision floating-point strided array `x`. +Adds a constant `alpha` to each element in a double-precision floating-point strided array. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -50,16 +50,14 @@ The function has the following parameters: - **x**: input [`Float64Array`][@stdlib/array/float64]. - **stride**: index increment. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to add a constant to every other element +The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var N = floor( x.length / 2 ); -dapx( N, 5.0, x, 2 ); +dapx( 4, 5.0, x, 2 ); // x => [ 3.0, 1.0, 8.0, -5.0, 9.0, 0.0, 4.0, -3.0 ] ``` @@ -67,23 +65,21 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial array... var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length/2 ); // Add a constant to every other element... -dapx( N, 5.0, x1, 2 ); +dapx( 3, 5.0, x1, 2 ); // x0 => [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ] ``` #### dapx.ndarray( N, alpha, x, stride, offset ) -Adds a constant `alpha` to each element in a double-precision floating-point strided array `x` using alternative indexing semantics. +Adds a constant `alpha` to each element in a double-precision floating-point strided array using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -98,7 +94,7 @@ The function has the following additional parameters: - **offset**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -117,7 +113,7 @@ dapx.ndarray( 3, 5.0, x, 1, x.length-3 ); ## Notes -- If `N <= 0`, both functions return `x` unchanged. +- If `N <= 0`, both functions return the strided array unchanged. @@ -130,27 +126,11 @@ dapx.ndarray( 3, 5.0, x, 1, x.length-3 ); ```javascript -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dapx = require( '@stdlib/blas/ext/base/dapx' ); -var rand; -var sign; -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - rand = round( randu()*100.0 ); - sign = randu(); - if ( sign < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - x[ i ] = sign * rand; -} +var x = filledarrayBy( 10, 'float64', discreteUniform( -100, 100 ) ); console.log( x ); dapx( x.length, 5.0, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.js index a8b1105782cd..1e2ec3f90065 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dapx = require( './../lib/dapx.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -40,12 +45,8 @@ var dapx = require( './../lib/dapx.js' ); */ function createBenchmark( len ) { var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.native.js index c96243119938..bec331f17271 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dapx = tryRequire( resolve( __dirname, './../lib/dapx.native.js' ) ); var opts = { 'skip': ( dapx instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -49,12 +50,8 @@ var opts = { */ function createBenchmark( len ) { var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.js index 7fccdbcd49bf..0a0fd5418756 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dapx = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -40,12 +45,8 @@ var dapx = require( './../lib/ndarray.js' ); */ function createBenchmark( len ) { var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.native.js index ea4007141b3e..77d9e12eeb14 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dapx = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dapx instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -49,12 +50,8 @@ var opts = { */ function createBenchmark( len ) { var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/repl.txt index 80e0c0b9d3aa..2f77bbf08b29 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/repl.txt @@ -3,13 +3,13 @@ Adds a constant to each element in a double-precision floating-point strided array. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N <= 0`, the function returns `x` unchanged. + If `N <= 0`, the function returns the strided array unchanged. Parameters ---------- @@ -23,40 +23,34 @@ Input array. stride: integer - Index increment for `x`. + Index increment. Returns ------- x: Float64Array - Input array `x`. + Input array. Examples -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var alpha = 5.0; - > {{alias}}( x.length, alpha, x, 1 ) + > {{alias}}( x.length, 5.0, x, 1 ) [ 3.0, 6.0, 8.0, 0.0, 9.0, 4.0, 2.0 ] // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > alpha = 5.0; - > var stride = 2; - > {{alias}}( N, alpha, x, stride ) + > {{alias}}( 3, 5.0, x, 2 ) [ 3.0, 1.0, 8.0, -5.0, 9.0, -1.0, -3.0 ] // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > alpha = 5.0; - > stride = 2; - > {{alias}}( N, alpha, x1, stride ) + > {{alias}}( 3, 5.0, x1, 2 ) [ 3.0, 3.0, 1.0, 5.0, -1.0 ] > x0 [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ] + {{alias}}.ndarray( N, alpha, x, stride, offset ) Adds a constant to each element in a double-precision floating-point strided array using alternative indexing semantics. @@ -77,30 +71,26 @@ Input array. stride: integer - Index increment for `x`. + Index increment. offset: integer - Starting index of `x`. + Starting index. Returns ------- x: Float64Array - Input array `x`. + Input array. Examples -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var alpha = 5.0; - > {{alias}}.ndarray( x.length, alpha, x, 1, 0 ) + > {{alias}}.ndarray( x.length, 5.0, x, 1, 0 ) [ 3.0, 6.0, 8.0, 0.0, 9.0, 4.0, 2.0 ] // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > alpha = 5.0; - > var stride = 2; - > {{alias}}.ndarray( N, alpha, x, stride, 1 ) + > {{alias}}.ndarray( 3, 5.0, x, 2, 1 ) [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/types/index.d.ts index 99f90326ef7f..1211a0d34637 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/docs/types/index.d.ts @@ -29,7 +29,7 @@ interface Routine { * @param alpha - constant * @param x - input array * @param stride - stride length - * @returns `x` + * @returns input array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -49,7 +49,7 @@ interface Routine { * @param x - input array * @param stride - stride length * @param offset - starting index - * @returns `x` + * @returns input array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -69,7 +69,7 @@ interface Routine { * @param alpha - constant * @param x - input array * @param stride - stride length -* @returns `x` +* @returns input array * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/examples/index.js index 55c571652632..58d039e922be 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/examples/index.js @@ -18,27 +18,11 @@ 'use strict'; -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dapx = require( './../lib' ); -var rand; -var sign; -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - rand = round( randu()*100.0 ); - sign = randu(); - if ( sign < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - x[ i ] = sign * rand; -} +var x = filledarrayBy( 10, 'float64', discreteUniform( -100, 100 ) ); console.log( x ); dapx( x.length, 5.0, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/dapx/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value node_dapx( 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_DOUBLE( env, alpha, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 2 ); + c_dapx( N, alpha, X, stride ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/dapx/src/addon.cpp deleted file mode 100644 index 7280d7e21b67..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/src/addon.cpp +++ /dev/null @@ -1,128 +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/blas/ext/base/dapx.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_dapx { - - /** - * Adds a constant to each element in a double-precision floating-point strided array. - * - * ## Notes - * - * - When called from JavaScript, the function expects four arguments: - * - * - `N`: number of indexed elements - * - `alpha`: scalar - * - `X`: input array - * - `strideX`: `X` stride length - */ - napi_value node_dapx( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 4; - napi_value argv[ 4 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 4 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 4 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double alpha; - status = napi_get_value_double( env, argv[ 1 ], &alpha ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - c_dapx( N, alpha, (double *)X, strideX ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dapx, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_dapx diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.js index 1ad083a0c40f..539c980f43f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.js @@ -86,7 +86,7 @@ tape( 'the function returns a reference to the input array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; @@ -102,7 +102,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.native.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.native.js index c90f015cb356..21e7a2240082 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.dapx.native.js @@ -95,7 +95,7 @@ tape( 'the function returns a reference to the input array', opts, function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; @@ -111,7 +111,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.js index 2cdbdfb45b20..db2e07f0f97a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.js @@ -86,7 +86,7 @@ tape( 'the function returns a reference to the input array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; @@ -102,7 +102,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.native.js index b7bce4bd8cca..d68862de0c82 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dapx/test/test.ndarray.native.js @@ -95,7 +95,7 @@ tape( 'the function returns a reference to the input array', opts, function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; @@ -111,7 +111,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md b/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md index aaff8be5b70d..2b3d3996877d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/README.md @@ -65,18 +65,15 @@ The function has the following parameters: - **y**: output [`Float64Array`][@stdlib/array/float64]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in the strided input array, ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); var y = new Float64Array( x.length ); -var N = floor( x.length / 2 ); - -var v = dcusum( N, 0.0, x, 2, y, 1 ); +var v = dcusum( 4, 0.0, x, 2, y, 1 ); // y => [ 1.0, 3.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ``` @@ -86,7 +83,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial arrays... var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); @@ -96,9 +92,7 @@ var y0 = new Float64Array( x0.length ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - -dcusum( N, 0.0, x1, -2, y1, 1 ); +dcusum( 4, 0.0, x1, -2, y1, 1 ); // y0 => [ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ] ``` @@ -121,18 +115,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in the strided input array starting from the second value and to store in the last `N` elements of the strided output array starting from the last element ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( x.length ); -var N = floor( x.length / 2 ); - -dcusum.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); +dcusum.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-1 ); // y => [ 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, -1.0, 1.0 ] ``` @@ -157,20 +148,14 @@ dcusum.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusum = require( '@stdlib/blas/ext/base/dcusum' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); +var y = new Float64Array( x.length ); -x = new Float64Array( 10 ); -y = new Float64Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.js index d8667fbc66bb..8745829bfb8e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var dcusum = require( './../lib/dcusum.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,8 @@ var dcusum = require( './../lib/dcusum.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var y; - var x; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.native.js index 102c7ddc358d..042b0ca0ac68 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -36,6 +37,7 @@ var dcusum = tryRequire( resolve( __dirname, './../lib/dcusum.native.js' ) ); var opts = { 'skip': ( dcusum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,15 +50,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.js index a6a296258833..1b02c85dd207 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var dcusum = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,8 @@ var dcusum = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.native.js index 346d16da2eaf..fb8838f4ae42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/benchmark/benchmark.ndarray.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -36,6 +37,7 @@ var dcusum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dcusum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,15 +50,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dcusum/docs/repl.txt index 6a1f4d707b4b..4f955bc57eba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/docs/repl.txt @@ -3,8 +3,8 @@ Computes the cumulative sum of double-precision floating-point strided array elements. - The `N` and `stride` parameters determine which elements in `x` and `y` are - accessed at runtime. + The `N` and `stride` parameters determine which elements in the strided + arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -47,8 +47,7 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float64}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 0.0, x, 2, y, 2 ) + > {{alias}}( 3, 0.0, x, 2, y, 2 ) [ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] // Using view offsets: @@ -56,12 +55,12 @@ > var y0 = new {{alias:@stdlib/array/float64}}( x0.length ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, 0.0, x1, 2, y1, 1 ) + > {{alias}}( 3, 0.0, x1, 2, y1, 1 ) [ -2.0, 0.0, -1.0 ] > y0 [ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ] + {{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY ) Computes the cumulative sum of double-precision floating-point strided array elements using alternative indexing semantics. @@ -112,8 +111,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float64}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 ) [ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/examples/index.js index dbfbab38024c..b5d935807754 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/examples/index.js @@ -18,20 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusum = require( './../lib' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); +var y = new Float64Array( x.length ); -x = new Float64Array( 10 ); -y = new Float64Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/dcusum/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', '[ 1.0, -1.0, 1.0 ] */ function dcusum( N, sum, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/dcusum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/dcusum.native.js index fe7cc207a196..6bd5c1cf1944 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/dcusum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/dcusum.native.js @@ -41,9 +41,8 @@ var addon = require( './../src/addon.node' ); * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * var y = new Float64Array( x.length ); -* var N = x.length; * -* var v = dcusum( N, 0.0, x, 1, y, 1 ); +* var v = dcusum( 3, 0.0, x, 1, y, 1 ); * // returns [ 1.0, -1.0, 1.0 ] */ function dcusum( N, sum, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/index.js index 7f3f016d0948..cbd737aaabf7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/index.js @@ -29,21 +29,18 @@ * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * var y = new Float64Array( x.length ); -* var N = x.length; * -* dcusum( N, 0.0, x, 1, y, 1 ); +* dcusum( 3, 0.0, x, 1, y, 1 ); * // y => [ 1.0, -1.0, 1.0 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dcusum = require( '@stdlib/blas/ext/base/dcusum' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( x.length ); -* var N = floor( x.length / 2 ); * -* dcusum.ndarray( N, 0.0, x, 2, 1, y, 1, 0 ); +* dcusum.ndarray( 4, 0.0, x, 2, 1, y, 1, 0 ); * // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.js index 883f2f03f5fa..bb01272fc4c1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.js @@ -40,13 +40,11 @@ var dcusumkbn = require( '@stdlib/blas/ext/base/dcusumkbn' ).ndarray; * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = dcusum( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = dcusum( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function dcusum( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.native.js index 5026d16a68d3..506154e84415 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/ndarray.native.js @@ -20,7 +20,8 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); var addon = require( './dcusum.native.js' ); @@ -41,26 +42,21 @@ var addon = require( './dcusum.native.js' ); * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = dcusum( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = dcusum( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function dcusum( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { var viewX; var viewY; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideY < 0 ) { - offsetY += (N-1) * strideY; - } - viewX = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewY = new Float64Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + viewX = offsetView( x, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + viewY = offsetView( y, offsetY ); addon( N, sum, viewX, strideX, viewY, strideY ); return y; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dcusum/manifest.json index eccdf0458c3d..89ef6d37a9f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/manifest.json @@ -1,42 +1,78 @@ { - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/dcusum.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/ext/base/dcusumkbn" - ] - } - ] + "options": { + "task": "build" + }, + "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", + "src": [ + "./src/dcusum.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/blas/ext/base/dcusumkbn" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/dcusum.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/dcusum.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/package.json b/lib/node_modules/@stdlib/blas/ext/base/dcusum/package.json index 6bd0222f5ae6..48c7704807cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/package.json @@ -74,5 +74,7 @@ "double", "float64array" ], - "__stdlib__": {} + "__stdlib__": { + "wasm": false + } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dcusum/src/addon.c new file mode 100644 index 000000000000..65e31134e1c6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/src/addon.c @@ -0,0 +1,51 @@ +/** +* @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/blas/ext/base/dcusum.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideY, argv, 4 ); + + napi_value v; + status = napi_create_double( env, stdlib_strided_dcusum( N, sum, X, strideX, Y, strideY ), &v ); + assert( status == napi_ok ); + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/dcusum/src/addon.cpp deleted file mode 100644 index 00013a58a5d0..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/src/addon.cpp +++ /dev/null @@ -1,164 +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/blas/ext/base/dcusum.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_dcusum { - - /** - * Computes the cumulative sum of double-precision floating-point strided array elements. - * - * ## Notes - * - * - When called from JavaScript, the function expects six arguments: - * - * - `N`: number of indexed elements - * - `sum`: initial sum - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: output array - * - `strideY`: `Y` stride length - */ - napi_value node_dcusum( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 6; - napi_value argv[ 6 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 6 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - bool res4; - status = napi_is_typedarray( env, argv[ 4 ], &res4 ); - assert( status == napi_ok ); - if ( res4 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype5; - status = napi_typeof( env, argv[ 5 ], &vtype5 ); - assert( status == napi_ok ); - if ( vtype5 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double sum; - status = napi_get_value_double( env, argv[ 1 ], &sum ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 5 ], &strideY ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_typedarray_type vtype4; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype4 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - stdlib_strided_dcusum( N, sum, (double *)X, strideX, (double *)Y, strideY ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dcusum, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_dcusum diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.js index 1c9c29a7d5d9..2595e4accf55 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusum = require( './../lib/dcusum.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 6', function test( t ) { - t.strictEqual( dcusum.length, 6, 'has expected arity' ); + t.strictEqual( dcusum.length, 6, 'returns expected value' ); t.end(); }); @@ -164,7 +163,6 @@ tape( 'the function supports an `x` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -180,9 +178,8 @@ tape( 'the function supports an `x` stride', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, y, 1 ); + dcusum( 3, 0.0, x, 2, y, 1 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -194,7 +191,6 @@ tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -210,9 +206,8 @@ tape( 'the function supports a `y` stride', function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusum( N, 0.0, x, 1, y, 2 ); + dcusum( 3, 0.0, x, 1, y, 2 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -224,7 +219,6 @@ tape( 'the function supports negative strides', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 2 @@ -240,9 +234,8 @@ tape( 'the function supports negative strides', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, -2, y, -1 ); + dcusum( 3, 0.0, x, -2, y, -1 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -254,7 +247,6 @@ tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -272,9 +264,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, y, -1 ); + dcusum( 3, 0.0, x, 2, y, -1 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); @@ -288,7 +279,6 @@ tape( 'the function supports view offsets', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float64Array([ @@ -312,9 +302,7 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - dcusum( N, 0.0, x1, -2, y1, 1 ); + dcusum( 3, 0.0, x1, -2, y1, 1 ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'deep equal' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.native.js index 63fb22963b41..330f2ca9f831 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.dcusum.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 6', opts, function test( t ) { - t.strictEqual( dcusum.length, 6, 'has expected arity' ); + t.strictEqual( dcusum.length, 6, 'returns expected value' ); t.end(); }); @@ -173,7 +172,6 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -189,9 +187,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, y, 1 ); + dcusum( 3, 0.0, x, 2, y, 1 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -203,7 +200,6 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -219,9 +215,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusum( N, 0.0, x, 1, y, 2 ); + dcusum( 3, 0.0, x, 1, y, 2 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -233,7 +228,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 2 @@ -249,9 +243,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, -2, y, -1 ); + dcusum( 3, 0.0, x, -2, y, -1 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -263,7 +256,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -281,9 +273,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, y, -1 ); + dcusum( 3, 0.0, x, 2, y, -1 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); @@ -297,7 +288,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float64Array([ @@ -321,9 +311,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - dcusum( N, 0.0, x1, -2, y1, 1 ); + dcusum( 3, 0.0, x1, -2, y1, 1 ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'deep equal' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.js index 4e3dafcee1e8..3127ac9e3aba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusum = require( './../lib/ndarray.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 8', function test( t ) { - t.strictEqual( dcusum.length, 8, 'has expected arity' ); + t.strictEqual( dcusum.length, 8, 'returns expected value' ); t.end(); }); @@ -164,7 +163,6 @@ tape( 'the function supports an `x` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -180,9 +178,8 @@ tape( 'the function supports an `x` stride', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, 0, y, 1, 0 ); + dcusum( 3, 0.0, x, 2, 0, y, 1, 0 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -194,7 +191,6 @@ tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -210,9 +206,8 @@ tape( 'the function supports a `y` stride', function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusum( N, 0.0, x, 1, 0, y, 2, 0 ); + dcusum( 3, 0.0, x, 1, 0, y, 2, 0 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -224,7 +219,6 @@ tape( 'the function supports negative strides', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 2 @@ -240,9 +234,8 @@ tape( 'the function supports negative strides', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, -2, x.length-1, y, -1, 2 ); + dcusum( 3, 0.0, x, -2, x.length-1, y, -1, 2 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -252,7 +245,6 @@ tape( 'the function supports negative strides', function test( t ) { tape( 'the function supports an `x` offset', function test( t ) { var expected; - var N; var x; var y; @@ -276,9 +268,8 @@ tape( 'the function supports an `x` offset', function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - dcusum( N, 0.0, x, 2, 1, y, 1, 0 ); + dcusum( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float64Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -288,7 +279,6 @@ tape( 'the function supports an `x` offset', function test( t ) { tape( 'the function supports a `y` offset', function test( t ) { var expected; - var N; var x; var y; @@ -312,9 +302,8 @@ tape( 'the function supports a `y` offset', function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - dcusum( N, 0.0, x, 1, 0, y, 2, 1 ); + dcusum( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float64Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); @@ -326,7 +315,6 @@ tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -344,9 +332,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, 0, y, -1, 2 ); + dcusum( 3, 0.0, x, 2, 0, y, -1, 2 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.native.js index a96a373dfd86..3ab3ce0ad5a1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dcusum/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 8', opts, function test( t ) { - t.strictEqual( dcusum.length, 8, 'has expected arity' ); + t.strictEqual( dcusum.length, 8, 'returns expected value' ); t.end(); }); @@ -173,7 +172,6 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -189,9 +187,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, 0, y, 1, 0 ); + dcusum( 3, 0.0, x, 2, 0, y, 1, 0 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -203,7 +200,6 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -219,9 +215,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusum( N, 0.0, x, 1, 0, y, 2, 0 ); + dcusum( 3, 0.0, x, 1, 0, y, 2, 0 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -233,7 +228,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 2 @@ -249,9 +243,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, -2, x.length-1, y, -1, 2 ); + dcusum( 3, 0.0, x, -2, x.length-1, y, -1, 2 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -261,7 +254,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { tape( 'the function supports an `x` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -285,9 +277,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - dcusum( N, 0.0, x, 2, 1, y, 1, 0 ); + dcusum( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float64Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -297,7 +288,6 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { tape( 'the function supports a `y` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -321,9 +311,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - dcusum( N, 0.0, x, 1, 0, y, 2, 1 ); + dcusum( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float64Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); @@ -335,7 +324,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -353,9 +341,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.0, 0.0 ]); - N = 3; - dcusum( N, 0.0, x, 2, 0, y, -1, 2 ); + dcusum( 3, 0.0, x, 2, 0, y, -1, 2 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfill/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dfill/manifest.json index 73f6ab7a43ce..ac53b3713b39 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfill/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dfill/manifest.json @@ -1,5 +1,7 @@ { - "options": {}, + "options": { + "task": "build" + }, "fields": [ { "field": "src", @@ -24,6 +26,7 @@ ], "confs": [ { + "task": "build", "src": [ "./src/dfill.c" ], @@ -37,10 +40,38 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] + }, + { + "task": "benchmark", + "src": [ + "./src/dfill.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/dfill.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfill/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dfill/src/addon.c index 68f6c2932b46..7dad3fc5f75e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfill/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfill/src/addon.c @@ -19,7 +19,7 @@ #include "stdlib/blas/ext/base/dfill.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" -#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_double.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float64array.h" #include @@ -35,7 +35,7 @@ static napi_value addon( 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_FLOAT( env, alpha, argv, 1 ); + STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 2 ); c_dfill( N, alpha, X, stride ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/README.md b/lib/node_modules/@stdlib/blas/ext/base/dnansum/README.md index 0953a2abe6a5..65d2e16fc993 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/README.md @@ -56,16 +56,14 @@ The function has the following parameters: - **x**: input [`Float64Array`][@stdlib/array/float64]. - **stride**: index increment for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the sum of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in the strided array, ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 1.0, 2.0, NaN, -7.0, NaN, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = dnansum( N, x, 2 ); +var v = dnansum( 4, x, 2 ); // returns 5.0 ``` @@ -75,14 +73,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float64Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = dnansum( N, x1, 2 ); +var v = dnansum( 4, x1, 2 ); // returns 5.0 ``` @@ -94,9 +89,8 @@ Computes the sum of double-precision floating-point strided array elements, igno var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -var N = x.length; -var v = dnansum.ndarray( N, x, 1, 0 ); +var v = dnansum.ndarray( 4, x, 1, 0 ); // returns 1.0 ``` @@ -104,16 +98,14 @@ The function has the following additional parameters: - **offset**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in the strided array starting from the second value ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = dnansum.ndarray( N, x, 2, 1 ); +var v = dnansum.ndarray( 4, x, 2, 1 ); // returns 5.0 ``` @@ -138,22 +130,20 @@ var v = dnansum.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float64Array = require( '@stdlib/array/float64' ); var dnansum = require( '@stdlib/blas/ext/base/dnansum' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( randu()*100.0 ); +function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( 0, 100 ); } + return NaN; } + +var x = filledarrayBy( 10, 'float64', clbk ); console.log( x ); var v = dnansum( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.js index 53d4f922b671..0fcbb379f7ee 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.js @@ -21,10 +21,11 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dnansum = require( './../lib/dnansum.js' ); @@ -39,18 +40,15 @@ var dnansum = require( './../lib/dnansum.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; + var x = filledarrayBy( len, 'float64', clbk ); + return benchmark; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; + function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( -10, 10 ); } + return NaN; } - return benchmark; function benchmark( b ) { var v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.native.js index 04f0fe1e1ba2..4105b34fb5a7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -48,18 +49,15 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; + var x = filledarrayBy( len, 'float64', clbk ); + return benchmark; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; + function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( -10, 10 ); } + return NaN; } - return benchmark; function benchmark( b ) { var v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.js index 90f347619bd4..a9a8301bca10 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.js @@ -21,10 +21,11 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dnansum = require( './../lib/ndarray.js' ); @@ -39,18 +40,15 @@ var dnansum = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; + var x = filledarrayBy( len, 'float64', clbk ); + return benchmark; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; + function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( -10, 10 ); } + return NaN; } - return benchmark; function benchmark( b ) { var v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.native.js index fd8a1af04a37..4555fee4066a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -48,18 +49,15 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; + var x = filledarrayBy( len, 'float64', clbk ); + return benchmark; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; + function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( -10, 10 ); } + return NaN; } - return benchmark; function benchmark( b ) { var v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dnansum/docs/repl.txt index 69eb7e0304e2..74ea39830edd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/docs/repl.txt @@ -3,8 +3,8 @@ Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and `stride` parameters determine which elements in the strided + array are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -36,19 +36,16 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 4, x, 2 ) 1.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 4, x1, 2 ) -1.0 + {{alias}}.ndarray( N, x, stride, offset ) Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using alternative indexing semantics. @@ -85,8 +82,7 @@ // Using offset parameter: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 4, x, 2, 1 ) -1.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/examples/index.js index c933d5744061..246ae3a016e3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/examples/index.js @@ -18,22 +18,19 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dnansum = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( randu()*100.0 ); +function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( 0, 100 ); } + return NaN; } + +var x = filledarrayBy( 10, 'float64', clbk ); console.log( x ); var v = dnansum( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/dnansum/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 1 ); + + napi_value v; + status = napi_create_double( env, stdlib_strided_dnansum( N, (double *)X, stride ), &v ); + assert( status == napi_ok ); + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/dnansum/src/addon.cpp deleted file mode 100644 index f940e5b56233..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/src/addon.cpp +++ /dev/null @@ -1,117 +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/blas/ext/base/dnansum.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_dnansum { - - /** - * Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_dnansum( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 1 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 2 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, stdlib_strided_dnansum( N, (double *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dnansum, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_dnansum diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.js index 05f6926805e8..e25debdc7b48 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var Float64Array = require( '@stdlib/array/float64' ); var dnansum = require( './../lib/dnansum.js' ); @@ -35,7 +34,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( dnansum.length, 3, 'has expected arity' ); + t.strictEqual( dnansum.length, 3, 'returns expected value' ); t.end(); }); @@ -106,7 +105,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -123,15 +121,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, 2 ); + v = dnansum( 5, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -148,8 +144,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, -2 ); + v = dnansum( 5, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -170,7 +165,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -188,9 +182,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dnansum( N, x1, 2 ); + v = dnansum( 5, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.native.js index e093e1e4761f..03cda2e6e3c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.dnansum.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -44,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 3', opts, function test( t ) { - t.strictEqual( dnansum.length, 3, 'has expected arity' ); + t.strictEqual( dnansum.length, 3, 'returns expected value' ); t.end(); }); @@ -197,7 +196,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -214,15 +212,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, 2 ); + v = dnansum( 5, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -239,8 +235,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, -2 ); + v = dnansum( 5, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -261,7 +256,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -279,9 +273,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dnansum( N, x1, 2 ); + v = dnansum( 5, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.js index 361ac6999269..48ca7508619b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var Float64Array = require( '@stdlib/array/float64' ); var dnansum = require( './../lib/ndarray.js' ); @@ -35,7 +34,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( dnansum.length, 4, 'has expected arity' ); + t.strictEqual( dnansum.length, 4, 'returns expected value' ); t.end(); }); @@ -106,7 +105,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -123,15 +121,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, 2, 0 ); + v = dnansum( 5, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -148,8 +144,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, -2, 8 ); + v = dnansum( 5, x, -2, 8 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -168,7 +163,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -184,9 +178,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, 2, 1 ); + v = dnansum( 5, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.native.js index a951545d2fca..b8dfd12b141a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnansum/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -44,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 4', opts, function test( t ) { - t.strictEqual( dnansum.length, 4, 'has expected arity' ); + t.strictEqual( dnansum.length, 4, 'returns expected value' ); t.end(); }); @@ -115,7 +114,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -132,15 +130,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, 2, 0 ); + v = dnansum( 5, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -157,8 +153,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, -2, 8 ); + v = dnansum( 5, x, -2, 8 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -177,7 +172,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -193,9 +187,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = dnansum( N, x, 2, 1 ); + v = dnansum( 5, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/docs/types/index.d.ts index e47c736c52eb..93cc7a29073f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/docs/types/index.d.ts @@ -146,7 +146,7 @@ interface Namespace { * @param alpha - constant * @param x - input array * @param stride - stride length - * @returns `x` + * @returns input array * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/README.md b/lib/node_modules/@stdlib/blas/ext/base/drev/README.md index cd96b556c811..303719c37d5d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/README.md @@ -49,16 +49,14 @@ The function has the following parameters: - **x**: input [`Float64Array`][@stdlib/array/float64]. - **stride**: index increment. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to reverse every other element +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to reverse every other element ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var N = floor( x.length / 2 ); -drev( N, x, 2 ); +drev( 4, x, 2 ); // x => [ -1.0, 1.0, 4.0, -5.0, 3.0, 0.0, -2.0, -3.0 ] ``` @@ -66,17 +64,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial array... var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length/2 ); // Reverse every other element... -drev( N, x1, 2 ); +drev( 3, x1, 2 ); // x0 => [ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ] ``` @@ -97,7 +93,7 @@ The function has the following additional parameters: - **offset**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -116,7 +112,7 @@ drev.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If `N <= 0`, both functions return `x` unchanged. +- If `N <= 0`, both functions return the strided array unchanged. - Where possible, one should "reverse" a strided array by negating its stride, which is an `O(1)` operation, in contrast to performing an in-place reversal, which is `O(N)`. However, in certain circumstances, this is not tenable, particularly when interfacing with libraries which assume and/or expect a specific memory layout (e.g., strided array elements arranged in memory in ascending order). In general, when working with strided arrays, only perform an in-place reversal when strictly necessary. @@ -130,27 +126,11 @@ drev.ndarray( 3, x, 1, x.length-3 ); ```javascript -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var drev = require( '@stdlib/blas/ext/base/drev' ); -var rand; -var sign; -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - rand = round( randu()*100.0 ); - sign = randu(); - if ( sign < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - x[ i ] = sign * rand; -} +var x = filledarrayBy( 10, 'float64', discreteUniform( -100.0, 100.0 ) ); console.log( x ); drev( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.js index ef6d4c5a25fa..208e82c3fcd1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var drev = require( './../lib/drev.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var drev = require( './../lib/drev.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.native.js index c4f94980dac4..645e5a8efc0b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var drev = tryRequire( resolve( __dirname, './../lib/drev.native.js' ) ); var opts = { 'skip': ( drev instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.js index bf79f3c4820e..12e2b5d4ee8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var drev = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var drev = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.native.js index 390183940e34..20fa4384274b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var drev = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( drev instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/drev/docs/repl.txt index d2dd4b869b41..c5e6d177e560 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/docs/repl.txt @@ -2,8 +2,8 @@ {{alias}}( N, x, stride ) Reverses a double-precision floating-point strided array in-place. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -24,7 +24,7 @@ Returns ------- x: Float64Array - Input array `x`. + Input array. Examples -------- @@ -33,21 +33,20 @@ > {{alias}}( x.length, x, 1 ) [ -3.0, -1.0, 4.0, -5.0, 3.0, 1.0, -2.0 ] - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, x, 2 ) + > {{alias}}( 3, x, 2 ) [ 4.0, 1.0, 3.0, -5.0, -2.0, -1.0, -3.0 ] // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, x1, 2 ) + > {{alias}}( 3, x1, 2 ) [ -6.0, 3.0, -4.0, 5.0, -2.0 ] > x0 [ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ] + {{alias}}.ndarray( N, x, stride, offset ) Reverses a double-precision floating-point strided array in-place using alternative indexing semantics. @@ -73,7 +72,7 @@ Returns ------- x: Float64Array - Input array `x`. + Input array. Examples -------- @@ -84,8 +83,7 @@ // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 3, x, 2, 1 ) [ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/drev/examples/c/example.c index 0f2392129f0c..4eaf0f085dc5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/examples/c/example.c @@ -24,13 +24,13 @@ int main( void ) { double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; // Specify the number of elements: - int N = 8; + const int N = 8; // Specify a stride: - int strideX = 1; + const int stride = 1; // Reverse the array: - c_drev( N, x, strideX ); + c_drev( N, x, stride ); // Print the result: for ( int i = 0; i < 8; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/drev/examples/index.js index 36b7a5a10a76..3b35c07cb4a2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/examples/index.js @@ -18,27 +18,11 @@ 'use strict'; -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var drev = require( './../lib' ); -var rand; -var sign; -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - rand = round( randu()*100.0 ); - sign = randu(); - if ( sign < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - x[ i ] = sign * rand; -} +var x = filledarrayBy( 10, 'float64', discreteUniform( -100.0, 100.0 ) ); console.log( x ); drev( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/drev/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 1 ); + c_drev( N, (double *)X, stride ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/drev/src/addon.cpp deleted file mode 100644 index 14b65e979918..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/src/addon.cpp +++ /dev/null @@ -1,115 +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/blas/ext/base/drev.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_drev { - - /** - * Reverses a double-precision floating-point strided array in-place. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `strideX`: `X` stride length - */ - napi_value node_drev( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res1; - status = napi_is_typedarray( env, argv[ 1 ], &res1 ); - assert( status == napi_ok ); - if ( res1 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 2 ], &strideX ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - c_drev( N, (double *)X, strideX ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_drev, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_drev diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.js b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.js index a2a1dba3809c..430aebd82bdf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.js @@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( drev.length, 3, 'has expected arity' ); + t.strictEqual( drev.length, 3, 'returns expected value' ); t.end(); }); @@ -92,7 +92,7 @@ tape( 'the function returns a reference to the input array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.native.js b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.native.js index 922d7b9c4e8c..a9aa8127a2d9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.drev.native.js @@ -43,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 3', opts, function test( t ) { - t.strictEqual( drev.length, 3, 'has expected arity' ); + t.strictEqual( drev.length, 3, 'returns expected value' ); t.end(); }); @@ -101,7 +101,7 @@ tape( 'the function returns a reference to the input array', opts, function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.js index 2e874f0d606e..0cac7202ec2c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.js @@ -51,7 +51,7 @@ tape( 'if a native implementation is available, the main export is the native im '@stdlib/utils/try-require': tryRequire }); - t.strictEqual( drev, mock, 'returns native implementation' ); + t.strictEqual( drev, mock, 'returns expected value' ); t.end(); function tryRequire() { @@ -73,7 +73,7 @@ tape( 'if a native implementation is not available, the main export is a JavaScr '@stdlib/utils/try-require': tryRequire }); - t.strictEqual( drev, main, 'returns JavaScript implementation' ); + t.strictEqual( drev, main, 'returns expected value' ); t.end(); function tryRequire() { diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.js index 50ad9f9d2083..9b7300bb8c66 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.js @@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( drev.length, 4, 'has expected arity' ); + t.strictEqual( drev.length, 4, 'returns expected value' ); t.end(); }); @@ -92,7 +92,7 @@ tape( 'the function returns a reference to the input array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.native.js index efe913a750f0..bac1a2c1ac4f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/drev/test/test.ndarray.native.js @@ -43,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 4', opts, function test( t ) { - t.strictEqual( drev.length, 4, 'has expected arity' ); + t.strictEqual( drev.length, 4, 'returns expected value' ); t.end(); }); @@ -101,7 +101,7 @@ tape( 'the function returns a reference to the input array', opts, function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/README.md b/lib/node_modules/@stdlib/blas/ext/base/dssum/README.md index bd69d901a0a3..7444c74e3662 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/README.md @@ -56,16 +56,14 @@ The function has the following parameters: - **x**: input [`Float32Array`][@stdlib/array/float32]. - **stride**: index increment for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the sum of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in the strided array, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = dssum( N, x, 2 ); +var v = dssum( 4, x, 2 ); // returns 5.0 ``` @@ -75,14 +73,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = dssum( N, x1, 2 ); +var v = dssum( 4, x1, 2 ); // returns 5.0 ``` @@ -94,9 +89,8 @@ Computes the sum of single-precision floating-point strided array elements using var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = dssum.ndarray( N, x, 1, 0 ); +var v = dssum.ndarray( 3, x, 1, 0 ); // returns 1.0 ``` @@ -104,16 +98,14 @@ The function has the following additional parameters: - **offset**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in the strided array starting from the second value ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = dssum.ndarray( N, x, 2, 1 ); +var v = dssum.ndarray( 4, x, 2, 1 ); // returns 5.0 ``` @@ -139,18 +131,11 @@ var v = dssum.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dssum = require( '@stdlib/blas/ext/base/dssum' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); console.log( x ); var v = dssum( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.js index 01a51ec1cc98..1f22551b10f7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var dssum = require( './../lib/dssum.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var dssum = require( './../lib/dssum.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.native.js index 9fe5ab4c911e..a7366cf7acb1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dssum = tryRequire( resolve( __dirname, './../lib/dssum.native.js' ) ); var opts = { 'skip': ( dssum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.js index a68c3c6f36a8..c9c692c44908 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var dssum = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var dssum = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.native.js index 2985a8c77b45..c7f00340e402 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dssum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dssum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dssum/docs/repl.txt index 63e7aaf05459..6bb151d10588 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/docs/repl.txt @@ -3,8 +3,8 @@ Computes the sum of single-precision floating-point strided array elements using extended accumulation and returning an extended precision result. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and `stride` parameters determine which elements in the strided + array are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -36,19 +36,16 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 3, x, 2 ) 1.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 3, x1, 2 ) -1.0 + {{alias}}.ndarray( N, x, stride, offset ) Computes the sum of single-precision floating-point strided array elements using extended accumulation and alternative indexing semantics and returning @@ -86,8 +83,7 @@ // Using offset parameter: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray(3, x, 2, 1 ) -1.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/examples/index.js index 3f7a4030829f..ef3795ebec46 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/examples/index.js @@ -18,18 +18,11 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dssum = require( './../lib' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 )); console.log( x ); var v = dssum( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/dssum/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); + + napi_value v; + napi_status status = napi_create_double( env, stdlib_strided_dssum( N, X, stride ), &v ); + assert( status == napi_ok ); + + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/dssum/src/addon.cpp deleted file mode 100644 index e706c6f86984..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/src/addon.cpp +++ /dev/null @@ -1,117 +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/blas/ext/base/dssum.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_dssum { - - /** - * Computes the sum of single-precision floating-point strided array elements using extended accumulation and returning an extended precision result. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_dssum( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 1 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 2 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, stdlib_strided_dssum( N, (float *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dssum, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_dssum diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.js index babb935a3977..3801b93734ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var dssum = require( './../lib/dssum.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( dssum.length, 3, 'has expected arity' ); + t.strictEqual( dssum.length, 3, 'returns expected value' ); t.end(); }); @@ -103,7 +102,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -118,15 +116,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, 2 ); + v = dssum( 4, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -142,8 +138,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, -2 ); + v = dssum( 4, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -172,7 +167,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -188,9 +182,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dssum( N, x1, 2 ); + v = dssum( 4, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.native.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.native.js index ce37b77801f8..20a983c9a6ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.dssum.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 3', opts, function test( t ) { - t.strictEqual( dssum.length, 3, 'has expected arity' ); + t.strictEqual( dssum.length, 3, 'returns expected value' ); t.end(); }); @@ -194,7 +193,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -209,15 +207,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, 2 ); + v = dssum( 4, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -233,8 +229,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, -2 ); + v = dssum( 4, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -263,7 +258,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -279,9 +273,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dssum( N, x1, 2 ); + v = dssum( 4, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.js index e19dbafec746..90d5b391eef5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var dssum = require( './../lib/ndarray.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( dssum.length, 4, 'has expected arity' ); + t.strictEqual( dssum.length, 4, 'returns expected value' ); t.end(); }); @@ -103,7 +102,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -118,15 +116,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, 2, 0 ); + v = dssum( 4, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -142,8 +138,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, -2, 6 ); + v = dssum( 4, x, -2, 6 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -170,7 +165,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -184,9 +178,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, 2, 1 ); + v = dssum( 4, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.native.js index 9f9ce44b57de..a6ad5ae5da3e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dssum/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 4', opts, function test( t ) { - t.strictEqual( dssum.length, 4, 'has expected arity' ); + t.strictEqual( dssum.length, 4, 'returns expected value' ); t.end(); }); @@ -112,7 +111,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -127,15 +125,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, 2, 0 ); + v = dssum( 4, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -151,8 +147,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, -2, 6 ); + v = dssum( 4, x, -2, 6 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -179,7 +174,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -193,9 +187,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dssum( N, x, 2, 1 ); + v = dssum( 4, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md b/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md index f5d6a80ae23c..4c14fd5482e7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md @@ -50,16 +50,14 @@ The function has the following parameters: - **x**: input [`Float32Array`][@stdlib/array/float32]. - **stride**: index increment. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to add a constant to every other element +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var N = floor( x.length / 2 ); -sapx( N, 5.0, x, 2 ); +sapx( 4, 5.0, x, 2 ); // x => [ 3.0, 1.0, 8.0, -5.0, 9.0, 0.0, 4.0, -3.0 ] ``` @@ -67,17 +65,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial array... var x0 = new Float32Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view... var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length/2 ); // Add a constant to every other element... -sapx( N, 5.0, x1, 2 ); +sapx( 3, 5.0, x1, 2 ); // x0 => [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ] ``` @@ -98,7 +94,7 @@ The function has the following additional parameters: - **offset**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -117,7 +113,7 @@ sapx.ndarray( 3, 5.0, x, 1, x.length-3 ); ## Notes -- If `N <= 0`, both functions return `x` unchanged. +- If `N <= 0`, both functions return the input array unchanged. @@ -130,27 +126,11 @@ sapx.ndarray( 3, 5.0, x, 1, x.length-3 ); ```javascript -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var sapx = require( '@stdlib/blas/ext/base/sapx' ); -var rand; -var sign; -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - rand = round( randu()*100.0 ); - sign = randu(); - if ( sign < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - x[ i ] = sign * rand; -} +var x = filledarrayBy( 10, 'float32', uniform( -100.0, 100.0 ) ); console.log( x ); sapx( x.length, 5.0, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.js index fc8f88420392..ffd0ff4adca6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sapx = require( './../lib/sapx.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var sapx = require( './../lib/sapx.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.native.js index ec66fd0dc0cd..c0d5da977159 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var sapx = tryRequire( resolve( __dirname, './../lib/sapx.native.js' ) ); var opts = { 'skip': ( sapx instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.js index 29b81da77048..b98d981d2b07 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sapx = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var sapx = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.native.js index cd198d07eff6..650ac428642a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var sapx = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( sapx instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt index 0c12d6d9d792..42e084cc080c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt @@ -3,13 +3,13 @@ Adds a constant to each element in a single-precision floating-point strided array. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N <= 0`, the function returns `x` unchanged. + If `N <= 0`, the function returns the strided array unchanged. Parameters ---------- @@ -23,40 +23,34 @@ Input array. stride: integer - Index increment for `x`. + Index increment. Returns ------- x: Float32Array - Input array `x`. + Input array. Examples -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var alpha = 5.0; - > {{alias}}( x.length, alpha, x, 1 ) + > {{alias}}( x.length, 5.0, x, 1 ) [ 3.0, 6.0, 8.0, 0.0, 9.0, 4.0, 2.0 ] // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > alpha = 5.0; - > var stride = 2; - > {{alias}}( N, alpha, x, stride ) + > {{alias}}( 3, 5.0, x, 2 ) [ 3.0, 1.0, 8.0, -5.0, 9.0, -1.0, -3.0 ] // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > alpha = 5.0; - > stride = 2; - > {{alias}}( N, alpha, x1, stride ) + > {{alias}}( 3, 5.0, x1, 2 ) [ 3.0, 3.0, 1.0, 5.0, -1.0 ] > x0 [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ] + {{alias}}.ndarray( N, alpha, x, stride, offset ) Adds a constant to each element in a single-precision floating-point strided array using alternative indexing semantics. @@ -77,30 +71,26 @@ Input array. stride: integer - Index increment for `x`. + Index increment. offset: integer - Starting index of `x`. + Starting index. Returns ------- x: Float32Array - Input array `x`. + Input array. Examples -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); - > var alpha = 5.0; - > {{alias}}.ndarray( x.length, alpha, x, 1, 0 ) + > {{alias}}.ndarray( x.length, 5.0, x, 1, 0 ) [ 3.0, 6.0, 8.0, 0.0, 9.0, 4.0, 2.0 ] // Using an index offset: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > alpha = 5.0; - > var stride = 2; - > {{alias}}.ndarray( N, alpha, x, stride, 1 ) + > {{alias}}.ndarray( 3, 5.0, x, 2, 1 ) [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/index.js index 650232f9d8e2..3e9bf3a73c87 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/index.js @@ -18,27 +18,12 @@ 'use strict'; -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var sapx = require( './../lib' ); -var rand; -var sign; -var x; -var i; +var x = filledarrayBy( 10, 'float32', uniform( -100.0, 100.0 ) ); -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - rand = round( randu()*100.0 ); - sign = randu(); - if ( sign < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - x[ i ] = sign * rand; -} console.log( x ); sapx( x.length, 5.0, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/sapx/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ) + c_sapx( N, alpha, X, strideX ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/sapx/src/addon.cpp deleted file mode 100644 index 2d511f5f5af3..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/src/addon.cpp +++ /dev/null @@ -1,128 +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/blas/ext/base/sapx.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_sapx { - - /** - * Adds a constant to each element in a single-precision floating-point strided array. - * - * ## Notes - * - * - When called from JavaScript, the function expects four arguments: - * - * - `N`: number of indexed elements - * - `alpha`: scalar - * - `X`: input array - * - `strideX`: `X` stride length - */ - napi_value node_sapx( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 4; - napi_value argv[ 4 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 4 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 4 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double alpha; - status = napi_get_value_double( env, argv[ 1 ], &alpha ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - c_sapx( N, (float)alpha, (float *)X, strideX ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_sapx, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_sapx diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.js index d6af1182cc72..d0413321a0c2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.js @@ -86,7 +86,7 @@ tape( 'the function returns a reference to the input array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { var expected; var x; @@ -102,7 +102,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the input array unchanged', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.native.js index 4936985b82af..0b99f94efe61 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.ndarray.native.js @@ -95,7 +95,7 @@ tape( 'the function returns a reference to the input array', opts, function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { var expected; var x; @@ -111,7 +111,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the input array unchanged', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.js index 462982a68478..014e47e5ad8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.js @@ -86,7 +86,7 @@ tape( 'the function returns a reference to the input array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { var expected; var x; @@ -102,7 +102,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the input array unchanged', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.native.js index 88f1b8126580..9f97b9f87a7c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/test/test.sapx.native.js @@ -95,7 +95,7 @@ tape( 'the function returns a reference to the input array', opts, function test t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { var expected; var x; @@ -111,7 +111,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if `alpha` equals `0`, the function returns `x` unchanged', opts, function test( t ) { +tape( 'if `alpha` equals `0`, the function returns the input array unchanged', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/README.md b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/README.md index effe09603735..7c7e27ae3ca7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/README.md @@ -56,16 +56,14 @@ The function has the following parameters: - **x**: input [`Float32Array`][@stdlib/array/float32]. - **stride**: index increment for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = sapxsum( N, 5.0, x, 2 ); +var v = sapxsum( 4, 5.0, x, 2 ); // returns 25.0 ``` @@ -75,14 +73,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = sapxsum( N, 5.0, x1, 2 ); +var v = sapxsum( 4, 5.0, x1, 2 ); // returns 25.0 ``` @@ -104,16 +99,14 @@ The function has the following additional parameters: - **offset**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameter supports indexing semantics based on a starting index. For example, to access every other value in `x` starting from the second value ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = sapxsum.ndarray( N, 5.0, x, 2, 1 ); +var v = sapxsum.ndarray( 4, 5.0, x, 2, 1 ); // returns 25.0 ``` @@ -138,22 +131,12 @@ var v = sapxsum.ndarray( N, 5.0, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var sapxsum = require( '@stdlib/blas/ext/base/sapxsum' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); console.log( x ); - -var v = sapxsum( x.length, 5.0, x, 1 ); -console.log( v ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.js index 7c7093df3de5..a3794363584e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var pkg = require( './../package.json' ).name; var sapxsum = require( './../lib/sapxsum.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var sapxsum = require( './../lib/sapxsum.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.native.js index d3efad2eac3f..f850b14b21dc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var sapxsum = tryRequire( resolve( __dirname, './../lib/sapxsum.native.js' ) ); var opts = { 'skip': ( sapxsum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.js index 2a7a6dddc356..8197e74a9950 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var pkg = require( './../package.json' ).name; var sapxsum = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var sapxsum = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.native.js index 4c3571eeb841..ad9b898716e7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var sapxsum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( sapxsum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/docs/repl.txt index 645a563ce6ef..b277320a58d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/docs/repl.txt @@ -3,8 +3,8 @@ Adds a constant to each single-precision floating-point strided array element and computes the sum. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided + array are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -37,27 +37,24 @@ > {{alias}}( x.length, 5.0, x, 1 ) 16.0 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, 5.0, x, stride ) + > {{alias}}( 3, 5.0, x, 2 ) 16.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, 5.0, x1, stride ) + > {{alias}}( 3, 5.0, x1, 2 ) 14.0 + {{alias}}.ndarray( N, alpha, x, stride, offset ) Adds a constant to each single-precision floating-point strided array element and computes the sum 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 + buffer, the offset parameter supports indexing semantics based on a starting index. Parameters @@ -90,9 +87,8 @@ 16.0 // Using offset parameter: - > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 5.0, x, 2, 1 ) + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); + > {{alias}}.ndarray( 3, 5.0, x, 2, 1 ) 14.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/examples/index.js index 7124ce61ec87..9dffd93b0fc8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/examples/index.js @@ -18,18 +18,11 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var sapxsum = require( './../lib' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); console.log( x ); var v = sapxsum( x.length, 5.0, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + + napi_value v; + status = napi_create_double( env, (double)stdlib_strided_sapxsum( N, alpha, X, stride ), &v ); + assert( status == napi_ok ); + + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/src/addon.cpp deleted file mode 100644 index 76b29f8d478a..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/src/addon.cpp +++ /dev/null @@ -1,130 +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/blas/ext/base/sapxsum.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_sapxsum { - - /** - * Adds a constant to each single-precision floating-point strided array element and computes the sum. - * - * ## Notes - * - * - When called from JavaScript, the function expects four arguments: - * - * - `N`: number of indexed elements - * - `alpha`: constant - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_sapxsum( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 4; - napi_value argv[ 4 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 4 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 4 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 2 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double alpha; - status = napi_get_value_double( env, argv[ 1 ], &alpha ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 3 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, (double)stdlib_strided_sapxsum( N, (float)alpha, (float *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_sapxsum, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_sapxsum diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.js index 61fc59e77d03..6b1841d188ca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var sapxsum = require( './../lib/ndarray.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 5', function test( t ) { - t.strictEqual( sapxsum.length, 5, 'has expected arity' ); + t.strictEqual( sapxsum.length, 5, 'returns expected value' ); t.end(); }); @@ -95,7 +94,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -110,15 +108,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, 2, 0 ); + v = sapxsum( 4, 5.0, x, 2, 0 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -133,8 +129,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, -2, 6 ); + v = sapxsum( 4, 5.0, x, -2, 6 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); @@ -153,7 +148,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -167,9 +161,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, 2, 1 ); + v = sapxsum( 4, 5.0, x, 2, 1 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.native.js index 70b804ddb7cf..6d6e3d7349d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 5', opts, function test( t ) { - t.strictEqual( sapxsum.length, 5, 'has expected arity' ); + t.strictEqual( sapxsum.length, 5, 'returns expected value' ); t.end(); }); @@ -104,7 +103,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -119,15 +117,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, 2, 0 ); + v = sapxsum( 4, 5.0, x, 2, 0 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -142,8 +138,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, -2, 6 ); + v = sapxsum( 4, 5.0, x, -2, 6 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); @@ -162,7 +157,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -176,9 +170,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, 2, 1 ); + v = sapxsum( 4, 5.0, x, 2, 1 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.js index 45232ed52350..e69c204bcc8f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var sapxsum = require( './../lib/sapxsum.js' ); @@ -95,7 +94,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -110,15 +108,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, 2 ); + v = sapxsum( 4, 5.0, x, 2 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -133,8 +129,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, -2 ); + v = sapxsum( 4, 5.0, x, -2 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); @@ -155,7 +150,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -171,9 +165,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = sapxsum( N, 5.0, x1, 2 ); + v = sapxsum( 4, 5.0, x1, 2 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.native.js index 81a46607b045..5776424c10a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sapxsum/test/test.sapxsum.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 4', opts, function test( t ) { - t.strictEqual( sapxsum.length, 4, 'has expected arity' ); + t.strictEqual( sapxsum.length, 4, 'returns expected value' ); t.end(); }); @@ -213,7 +212,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -228,15 +226,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, 2 ); + v = sapxsum( 4, 5.0, x, 2 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -251,8 +247,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = sapxsum( N, 5.0, x, -2 ); + v = sapxsum( 4, 5.0, x, -2 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); @@ -273,7 +268,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -289,9 +283,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = sapxsum( N, 5.0, x1, 2 ); + v = sapxsum( 4, 5.0, x1, 2 ); t.strictEqual( v, 25.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/README.md b/lib/node_modules/@stdlib/blas/ext/base/scusum/README.md index 198ec8975cf3..fc090f8e6bf8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/README.md @@ -65,18 +65,15 @@ The function has the following parameters: - **y**: output [`Float32Array`][@stdlib/array/float32]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in the strided input array, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); var y = new Float32Array( x.length ); -var N = floor( x.length / 2 ); - -var v = scusum( N, 0.0, x, 2, y, 1 ); +var v = scusum( 4, 0.0, x, 2, y, 1 ); // y => [ 1.0, 3.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ``` @@ -86,7 +83,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial arrays... var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); @@ -96,9 +92,7 @@ var y0 = new Float32Array( x0.length ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - -scusum( N, 0.0, x1, -2, y1, 1 ); +scusum( 4, 0.0, x1, -2, y1, 1 ); // y0 => [ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ] ``` @@ -121,18 +115,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, offsetX and offsetY parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in the strided input array starting from the second value and to store in the last `N` elements of the strided output array starting from the last element ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var y = new Float32Array( x.length ); -var N = floor( x.length / 2 ); - -scusum.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); +scusum.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-1 ); // y => [ 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, -1.0, 1.0 ] ``` @@ -157,20 +148,13 @@ scusum.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float32Array = require( '@stdlib/array/float32' ); var scusum = require( '@stdlib/blas/ext/base/scusum' ); -var y; -var x; -var i; - -x = new Float32Array( 10 ); -y = new Float32Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var y = new Float32Array( x.length ); console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.js index 962e406fa06b..69c251af827c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Float32Array = require( '@stdlib/array/float32' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var scusum = require( './../lib/scusum.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,8 @@ var scusum = require( './../lib/scusum.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var y; - var x; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.native.js index 02c902ea4406..942a4ddda88a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -36,6 +37,7 @@ var scusum = tryRequire( resolve( __dirname, './../lib/scusum.native.js' ) ); var opts = { 'skip': ( scusum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,15 +50,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.js index 125ca2e4786d..00e014a1fe5e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var scusum = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,8 @@ var scusum = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.native.js index df723354c058..0a920dce4110 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/benchmark/benchmark.ndarray.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -36,6 +37,7 @@ var scusum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( scusum instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,15 +50,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scusum/docs/repl.txt index 568765828a01..d6e5e3124514 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/docs/repl.txt @@ -3,8 +3,8 @@ Computes the cumulative sum of single-precision floating-point strided array elements. - The `N` and `stride` parameters determine which elements in `x` and `y` are - accessed at runtime. + The `N` and `stride` parameters determine which elements in the strided + arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -47,8 +47,7 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 0.0, x, 2, y, 2 ) + > {{alias}}( 3, 0.0, x, 2, y, 2 ) [ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] // Using view offsets: @@ -56,12 +55,12 @@ > var y0 = new {{alias:@stdlib/array/float32}}( x0.length ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, 0.0, x1, 2, y1, 1 ) + > {{alias}}( 3, 0.0, x1, 2, y1, 1 ) [ -2.0, 0.0, -1.0 ] > y0 [ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ] + {{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY ) Computes the cumulative sum of single-precision floating-point strided array elements using alternative indexing semantics. @@ -112,8 +111,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 ) [ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/examples/index.js index 15f6a4e1c3ef..6a92d6ab1267 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/examples/index.js @@ -18,20 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float32Array = require( '@stdlib/array/float32' ); var scusum = require( './../lib' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var y = new Float32Array( x.length ); -x = new Float32Array( 10 ); -y = new Float32Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/scusum/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' [ 1.0, -1.0, 1.0 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var scusum = require( '@stdlib/blas/ext/base/scusum' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float32Array( x.length ); -* var N = floor( x.length / 2 ); * -* scusum.ndarray( N, 0.0, x, 2, 1, y, 1, 0 ); +* scusum.ndarray( 4, 0.0, x, 2, 1, y, 1, 0 ); * // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.js index 0b13094e661b..fc8c631d22b0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.js @@ -40,13 +40,11 @@ var scusumkbn = require( '@stdlib/blas/ext/base/scusumkbn' ).ndarray; * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float32Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = scusum( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = scusum( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function scusum( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.native.js index a5595b017394..3f05e52ab35a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/ndarray.native.js @@ -20,7 +20,8 @@ // MODULES // -var Float32Array = require( '@stdlib/array/float32' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); var addon = require( './scusum.native.js' ); @@ -41,26 +42,21 @@ var addon = require( './scusum.native.js' ); * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float32Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = scusum( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = scusum( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function scusum( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { var viewX; var viewY; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideY < 0 ) { - offsetY += (N-1) * strideY; - } - viewX = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewY = new Float32Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + viewX = offsetView( x, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + viewY = offsetView( y, offsetY ); addon( N, sum, viewX, strideX, viewY, strideY ); return y; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.js index 8e1e046d9304..6c0613927f8e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.js @@ -41,9 +41,8 @@ var scusumkbn = require( '@stdlib/blas/ext/base/scusumkbn' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); * var y = new Float32Array( x.length ); -* var N = x.length; * -* var v = scusum( N, 0.0, x, 1, y, 1 ); +* var v = scusum( 3, 0.0, x, 1, y, 1 ); * // returns [ 1.0, -1.0, 1.0 ] */ function scusum( N, sum, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.native.js index 804e5fb5590a..96b9f767476f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/lib/scusum.native.js @@ -41,9 +41,8 @@ var addon = require( './../src/addon.node' ); * * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); * var y = new Float32Array( x.length ); -* var N = x.length; * -* var v = scusum( N, 0.0, x, 1, y, 1 ); +* var v = scusum( 3, 0.0, x, 1, y, 1 ); * // returns [ 1.0, -1.0, 1.0 ] */ function scusum( N, sum, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/scusum/manifest.json index 0c7e02a28ec0..9f852154bd20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/manifest.json @@ -1,42 +1,78 @@ { - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/scusum.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/blas/ext/base/scusumkbn" - ] - } - ] + "options": { + "task": "build" + }, + "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", + "src": [ + "./src/scusum.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/ext/base/scusumkbn", + "stdlib/napi/export", + "stdlib/napi/argv", + "stdlib/napi/argv-int64", + "stdlib/napi/argv-float", + "stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/scusum.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/scusum.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/package.json b/lib/node_modules/@stdlib/blas/ext/base/scusum/package.json index 0dcc765d7ae8..bb44b07c32ff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/package.json @@ -75,5 +75,7 @@ "single", "float32array" ], - "__stdlib__": {} + "__stdlib__": { + "wasm": false + } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/scusum/src/addon.c new file mode 100644 index 000000000000..93edb179b7c5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/src/addon.c @@ -0,0 +1,48 @@ +/** +* @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/blas/ext/base/scusum.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideY, argv, 4 ); + stdlib_strided_scusum( N, sum, X, strideX, Y, strideY ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/scusum/src/addon.cpp deleted file mode 100644 index 6a1382842289..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/src/addon.cpp +++ /dev/null @@ -1,164 +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/blas/ext/base/scusum.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_scusum { - - /** - * Computes the cumulative sum of single-precision floating-point strided array elements. - * - * ## Notes - * - * - When called from JavaScript, the function expects six arguments: - * - * - `N`: number of indexed elements - * - `sum`: initial sum - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: output array - * - `strideY`: `Y` stride length - */ - napi_value node_scusum( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 6; - napi_value argv[ 6 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 6 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - bool res4; - status = napi_is_typedarray( env, argv[ 4 ], &res4 ); - assert( status == napi_ok ); - if ( res4 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype5; - status = napi_typeof( env, argv[ 5 ], &vtype5 ); - assert( status == napi_ok ); - if ( vtype5 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double sum; - status = napi_get_value_double( env, argv[ 1 ], &sum ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 5 ], &strideY ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_typedarray_type vtype4; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype4 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - stdlib_strided_scusum( N, (float)sum, (float *)X, strideX, (float *)Y, strideY ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_scusum, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_scusum diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.js index ffcae20fc948..da0034ad3831 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var scusum = require( './../lib/ndarray.js' ); @@ -164,7 +163,6 @@ tape( 'the function supports an `x` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -180,9 +178,8 @@ tape( 'the function supports an `x` stride', function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, 0, y, 1, 0 ); + scusum( 3, 0.0, x, 2, 0, y, 1, 0 ); expected = new Float32Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -194,7 +191,6 @@ tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -210,9 +206,8 @@ tape( 'the function supports a `y` stride', function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - scusum( N, 0.0, x, 1, 0, y, 2, 0 ); + scusum( 3, 0.0, x, 1, 0, y, 2, 0 ); expected = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -224,7 +219,6 @@ tape( 'the function supports negative strides', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 2 @@ -240,9 +234,8 @@ tape( 'the function supports negative strides', function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, -2, x.length-1, y, -1, 2 ); + scusum( 3, 0.0, x, -2, x.length-1, y, -1, 2 ); expected = new Float32Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -252,7 +245,6 @@ tape( 'the function supports negative strides', function test( t ) { tape( 'the function supports an `x` offset', function test( t ) { var expected; - var N; var x; var y; @@ -276,9 +268,8 @@ tape( 'the function supports an `x` offset', function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - scusum( N, 0.0, x, 2, 1, y, 1, 0 ); + scusum( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float32Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -288,7 +279,6 @@ tape( 'the function supports an `x` offset', function test( t ) { tape( 'the function supports a `y` offset', function test( t ) { var expected; - var N; var x; var y; @@ -312,9 +302,8 @@ tape( 'the function supports a `y` offset', function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - scusum( N, 0.0, x, 1, 0, y, 2, 1 ); + scusum( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float32Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); @@ -326,7 +315,6 @@ tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -344,9 +332,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, 0, y, -1, 2 ); + scusum( 3, 0.0, x, 2, 0, y, -1, 2 ); expected = new Float32Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.native.js index ad957b847d10..3ae5cb53505c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -173,7 +172,6 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -189,9 +187,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, 0, y, 1, 0 ); + scusum( 3, 0.0, x, 2, 0, y, 1, 0 ); expected = new Float32Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -203,7 +200,6 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -219,9 +215,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - scusum( N, 0.0, x, 1, 0, y, 2, 0 ); + scusum( 3, 0.0, x, 1, 0, y, 2, 0 ); expected = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -233,7 +228,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 2 @@ -249,9 +243,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, -2, x.length-1, y, -1, 2 ); + scusum( 3, 0.0, x, -2, x.length-1, y, -1, 2 ); expected = new Float32Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -261,7 +254,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { tape( 'the function supports an `x` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -285,9 +277,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - scusum( N, 0.0, x, 2, 1, y, 1, 0 ); + scusum( 3, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float32Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -297,7 +288,6 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { tape( 'the function supports a `y` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -321,9 +311,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - scusum( N, 0.0, x, 1, 0, y, 2, 1 ); + scusum( 3, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float32Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); @@ -335,7 +324,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -353,9 +341,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, 0, y, -1, 2 ); + scusum( 3, 0.0, x, 2, 0, y, -1, 2 ); expected = new Float32Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.js index b1973a63519a..85badd1053d9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var scusum = require( './../lib/scusum.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 6', function test( t ) { - t.strictEqual( scusum.length, 6, 'has expected arity' ); + t.strictEqual( scusum.length, 6, 'returns expected value' ); t.end(); }); @@ -164,7 +163,6 @@ tape( 'the function supports an `x` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -180,9 +178,8 @@ tape( 'the function supports an `x` stride', function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, y, 1 ); + scusum( 3, 0.0, x, 2, y, 1 ); expected = new Float32Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -194,7 +191,6 @@ tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -210,9 +206,8 @@ tape( 'the function supports a `y` stride', function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - scusum( N, 0.0, x, 1, y, 2 ); + scusum( 3, 0.0, x, 1, y, 2 ); expected = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -224,7 +219,6 @@ tape( 'the function supports negative strides', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 2 @@ -240,9 +234,8 @@ tape( 'the function supports negative strides', function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, -2, y, -1 ); + scusum( 3, 0.0, x, -2, y, -1 ); expected = new Float32Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -254,7 +247,6 @@ tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -272,9 +264,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, y, -1 ); + scusum( 3, 0.0, x, 2, y, -1 ); expected = new Float32Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); @@ -288,7 +279,6 @@ tape( 'the function supports view offsets', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float32Array([ @@ -312,9 +302,7 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - scusum( N, 0.0, x1, -2, y1, 1 ); + scusum( 3, 0.0, x1, -2, y1, 1 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'deep equal' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.native.js index e5b184951519..ac0a872c7e72 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusum/test/test.scusum.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 6', opts, function test( t ) { - t.strictEqual( scusum.length, 6, 'has expected arity' ); + t.strictEqual( scusum.length, 6, 'returns expected value' ); t.end(); }); @@ -173,7 +172,6 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -189,9 +187,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, y, 1 ); + scusum( 3, 0.0, x, 2, y, 1 ); expected = new Float32Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -203,7 +200,6 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -219,9 +215,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - scusum( N, 0.0, x, 1, y, 2 ); + scusum( 3, 0.0, x, 1, y, 2 ); expected = new Float32Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -233,7 +228,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 2 @@ -249,9 +243,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, -2, y, -1 ); + scusum( 3, 0.0, x, -2, y, -1 ); expected = new Float32Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); @@ -263,7 +256,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var expected; var x; var y; - var N; x = new Float32Array([ 1.0, // 0 @@ -281,9 +273,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.0, 0.0 ]); - N = 3; - scusum( N, 0.0, x, 2, y, -1 ); + scusum( 3, 0.0, x, 2, y, -1 ); expected = new Float32Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); @@ -297,7 +288,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float32Array([ @@ -321,9 +311,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - scusum( N, 0.0, x1, -2, y1, 1 ); + scusum( 3, 0.0, x1, -2, y1, 1 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'deep equal' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/README.md b/lib/node_modules/@stdlib/blas/ext/base/scusumors/README.md index 6cd5c5951743..bc247cf7aae6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/README.md @@ -65,18 +65,15 @@ The function has the following parameters: - **y**: output [`Float32Array`][@stdlib/array/float32]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); var y = new Float32Array( x.length ); -var N = floor( x.length / 2 ); - -var v = scusumors( N, 0.0, x, 2, y, 1 ); +var v = scusumors( 4, 0.0, x, 2, y, 1 ); // y => [ 1.0, 3.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ``` @@ -86,7 +83,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial arrays... var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); @@ -96,9 +92,7 @@ var y0 = new Float32Array( x0.length ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - -scusumors( N, 0.0, x1, -2, y1, 1 ); +scusumors( 4, 0.0, x1, -2, y1, 1 ); // y0 => [ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ] ``` @@ -121,18 +115,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var y = new Float32Array( x.length ); -var N = floor( x.length / 2 ); - -scusumors.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); +scusumors.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-1 ); // y => [ 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, -1.0, 1.0 ] ``` @@ -144,7 +135,7 @@ scusumors.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ## Notes -- If `N <= 0`, both functions return `y` unchanged. +- If `N <= 0`, both functions return the output array unchanged. - Ordinary recursive summation (i.e., a "simple" sum) is performant, but can incur significant numerical error. If performance is paramount and error tolerated, using ordinary recursive summation is acceptable; in all other cases, exercise due caution. @@ -158,20 +149,14 @@ scusumors.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float32Array = require( '@stdlib/array/float32' ); var scusumors = require( '@stdlib/blas/ext/base/scusumors' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var y = new Float32Array( x.length ); -x = new Float32Array( 10 ); -y = new Float32Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.js index 0cd850d46e76..2f42a28b2db3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -41,13 +42,10 @@ var scusumors = require( './../lib/scusumors.js' ); function createBenchmark( len ) { var y; var x; - var i; - x = new Float32Array( len ); + x = filledarrayBy( len, 'float32', uniform( -10.0, 10.0 ) ); y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.native.js index 1b3f1a4e25b3..4256c5fc0c77 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -50,13 +51,10 @@ var opts = { function createBenchmark( len ) { var x; var y; - var i; - x = new Float32Array( len ); + x = filledarrayBy( len, 'float32', uniform( -10.0, 10.0 ) ); y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.js index e4c8659972a1..2c987c262a8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -41,13 +42,10 @@ var scusumors = require( './../lib/ndarray.js' ); function createBenchmark( len ) { var x; var y; - var i; - x = new Float32Array( len ); + x = filledarrayBy( len, 'float32', uniform( -10.0, 10.0 ) ); y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.native.js index c90db53814c7..37cc520539ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/benchmark/benchmark.ndarray.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -50,13 +51,10 @@ var opts = { function createBenchmark( len ) { var x; var y; - var i; - x = new Float32Array( len ); + x = filledarrayBy( len, 'float32', uniform( -10.0, 10.0 ) ); y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scusumors/docs/repl.txt index 86553568a61b..c16d450b275c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/docs/repl.txt @@ -3,8 +3,8 @@ Computes the cumulative sum of single-precision floating-point strided array elements using ordinary recursive summation. - The `N` and `stride` parameters determine which elements in `x` and `y` are - accessed at runtime. + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -44,11 +44,10 @@ > {{alias}}( x.length, 0.0, x, 1, y, 1 ) [ 1.0, -1.0, 1.0 ] - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 0.0, x, 2, y, 2 ) + > {{alias}}( 3, 0.0, x, 2, y, 2 ) [ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] // Using view offsets: @@ -56,12 +55,12 @@ > var y0 = new {{alias:@stdlib/array/float32}}( x0.length ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, 0.0, x1, 2, y1, 1 ) + > {{alias}}( 3, 0.0, x1, 2, y1, 1 ) [ -2.0, 0.0, -1.0 ] > y0 [ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ] + {{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY ) Computes the cumulative sum of single-precision floating-point strided array elements using ordinary recursive summation and alternative indexing @@ -113,8 +112,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 ) [ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/examples/index.js index cc8eb5a7773c..7bb9a381a349 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/examples/index.js @@ -18,20 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var scusumors = require( './../lib' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var y = new Float32Array( x.length ); -x = new Float32Array( 10 ); -y = new Float32Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/scusumors/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.js index f05bb342b5ba..210f8a30aa55 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.js @@ -40,13 +40,11 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float32Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = scusumors( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = scusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function scusumors( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.native.js index 7edd250e3ee3..1e5087b5aa64 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/lib/ndarray.native.js @@ -20,7 +20,8 @@ // MODULES // -var Float32Array = require( '@stdlib/array/float32' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); var addon = require( './scusumors.native.js' ); @@ -41,26 +42,23 @@ var addon = require( './scusumors.native.js' ); * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float32Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = scusumors( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = scusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function scusumors( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { var viewX; var viewY; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideY < 0 ) { - offsetY += (N-1) * strideY; - } - viewX = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewY = new Float32Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = offsetView( x, offsetX ); + viewY = offsetView( y, offsetY ); + addon( N, sum, viewX, strideX, viewY, strideY ); return y; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/scusumors/manifest.json index dd9cf0d5f8f5..17c6d6c978f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/manifest.json @@ -1,40 +1,77 @@ { - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/scusumors.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [] - } - ] + "options": { + "task": "build" + }, + "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", + "src": [ + "./src/scusumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/scusumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/scusumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/package.json b/lib/node_modules/@stdlib/blas/ext/base/scusumors/package.json index 5c17c6a8bd56..f0d3a1630627 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/package.json @@ -76,5 +76,7 @@ "single", "float32array" ], - "__stdlib__": {} + "__stdlib__": { + "wasm": false + } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/scusumors/src/addon.c new file mode 100644 index 000000000000..ace217d1c331 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/src/addon.c @@ -0,0 +1,51 @@ +/** +* @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/blas/ext/base/scusumors.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, sum, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); + + stdlib_strided_scusumors( N, sum, X, strideX, Y, strideY ); + + return NULL; +} + + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) + diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/scusumors/src/addon.cpp deleted file mode 100644 index d3152f5005fa..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/src/addon.cpp +++ /dev/null @@ -1,164 +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/blas/ext/base/scusumors.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_scusumors { - - /** - * Computes the cumulative sum of single-precision floating-point strided array elements using ordinary recursive summation. - * - * ## Notes - * - * - When called from JavaScript, the function expects six arguments: - * - * - `N`: number of indexed elements - * - `sum`: initial sum - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: output array - * - `strideY`: `Y` stride length - */ - napi_value node_scusumors( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 6; - napi_value argv[ 6 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 6 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - bool res4; - status = napi_is_typedarray( env, argv[ 4 ], &res4 ); - assert( status == napi_ok ); - if ( res4 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype5; - status = napi_typeof( env, argv[ 5 ], &vtype5 ); - assert( status == napi_ok ); - if ( vtype5 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double sum; - status = napi_get_value_double( env, argv[ 1 ], &sum ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 5 ], &strideY ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_typedarray_type vtype4; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype4 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - stdlib_strided_scusumors( N, (float)sum, (float *)X, strideX, (float *)Y, strideY ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_scusumors, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_scusumors diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.js index 5137803a2b94..fd828a164066 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var scusumors = require( './../lib/ndarray.js' ); @@ -141,7 +140,7 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; var y; @@ -152,10 +151,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumors( -1, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumors( 0, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -268,7 +267,6 @@ tape( 'the function supports negative strides', function test( t ) { tape( 'the function supports an `x` offset', function test( t ) { var expected; - var N; var x; var y; @@ -292,9 +290,8 @@ tape( 'the function supports an `x` offset', function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - scusumors( N, 0.0, x, 2, 1, y, 1, 0 ); + scusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float32Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -304,7 +301,6 @@ tape( 'the function supports an `x` offset', function test( t ) { tape( 'the function supports a `y` offset', function test( t ) { var expected; - var N; var x; var y; @@ -328,9 +324,8 @@ tape( 'the function supports a `y` offset', function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - scusumors( N, 0.0, x, 1, 0, y, 2, 1 ); + scusumors( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float32Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.native.js index 6afb73a6a122..e62212021968 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -150,7 +149,7 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; var y; @@ -161,10 +160,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumors( -1, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumors( 0, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -277,7 +276,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { tape( 'the function supports an `x` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -301,9 +299,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - scusumors( N, 0.0, x, 2, 1, y, 1, 0 ); + scusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float32Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -313,7 +310,6 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { tape( 'the function supports a `y` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -337,9 +333,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - scusumors( N, 0.0, x, 1, 0, y, 2, 1 ); + scusumors( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float32Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.js index 5cdc4875ad20..eaec9e782bce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var scusumors = require( './../lib/scusumors.js' ); @@ -141,7 +140,7 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', function test( t ) { var expected; var x; var y; @@ -152,10 +151,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumors( -1, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumors( 0, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -304,7 +303,6 @@ tape( 'the function supports view offsets', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float32Array([ @@ -328,9 +326,7 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - scusumors( N, 0.0, x1, -2, y1, 1 ); + scusumors( 3, 0.0, x1, -2, y1, 1 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.native.js index 7a32188b0b38..f8241221beb7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumors/test/test.scusumors.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -150,7 +149,7 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; var y; @@ -161,10 +160,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumors( -1, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumors( 0, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -313,7 +312,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float32Array([ @@ -337,9 +335,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - scusumors( N, 0.0, x1, -2, y1, 1 ); + scusumors( 3, 0.0, x1, -2, y1, 1 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/README.md index 1254ee178fb2..99de471245d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/README.md @@ -65,18 +65,15 @@ The function has the following parameters: - **y**: output [`Float32Array`][@stdlib/array/float32]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); var y = new Float32Array( x.length ); -var N = floor( x.length / 2 ); - -var v = scusumpw( N, 0.0, x, 2, y, 1 ); +var v = scusumpw( 4, 0.0, x, 2, y, 1 ); // y => [ 1.0, 3.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ``` @@ -86,7 +83,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); // Initial arrays... var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); @@ -96,9 +92,7 @@ var y0 = new Float32Array( x0.length ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - -scusumpw( N, 0.0, x1, -2, y1, 1 ); +scusumpw( 4, 0.0, x1, -2, y1, 1 ); // y0 => [ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ] ``` @@ -125,14 +119,11 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var y = new Float32Array( x.length ); -var N = floor( x.length / 2 ); - -scusumpw.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); +scusumpw.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-1 ); // y => [ 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, -1.0, 1.0 ] ``` @@ -158,20 +149,14 @@ scusumpw.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float32Array = require( '@stdlib/array/float32' ); var scusumpw = require( '@stdlib/blas/ext/base/scusumpw' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var y = new Float32Array( x.length ); -x = new Float32Array( 10 ); -y = new Float32Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.js index b38a94746a16..9140d18b1123 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var scusumpw = require( './../lib/scusumpw.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,9 @@ var scusumpw = require( './../lib/scusumpw.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var y; - var x; - var i; + var y = new Float32Array( len ); + var x = filledarrayBy( len, 'float32', rand ); - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.native.js index 504c1bcae895..e63e3363000e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -36,6 +37,7 @@ var scusumpw = tryRequire( resolve( __dirname, './../lib/scusumpw.native.js' ) ) var opts = { 'skip': ( scusumpw instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,15 +50,9 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.js index f030f41e30ef..0a6f1bc6c736 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var scusumpw = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,9 @@ var scusumpw = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.native.js index ee290adbeb36..0a386bb1269e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/benchmark/benchmark.ndarray.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float32Array = require( '@stdlib/array/float32' ); @@ -36,6 +37,7 @@ var scusumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( scusumpw instanceof Error ) }; +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // @@ -48,15 +50,9 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; + var x = filledarrayBy( len, 'float32', rand ); + var y = new Float32Array( len ); - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/docs/repl.txt index cfb10565541b..70e9f3b55348 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/docs/repl.txt @@ -3,8 +3,8 @@ Computes the cumulative sum of single-precision floating-point strided array elements using pairwise summation. - The `N` and `stride` parameters determine which elements in `x` and `y` are - accessed at runtime. + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -44,11 +44,10 @@ > {{alias}}( x.length, 0.0, x, 1, y, 1 ) [ 1.0, -1.0, 1.0 ] - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 0.0, x, 2, y, 2 ) + > {{alias}}( 3, 0.0, x, 2, y, 2 ) [ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] // Using view offsets: @@ -56,12 +55,12 @@ > var y0 = new {{alias:@stdlib/array/float32}}( x0.length ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, 0.0, x1, 2, y1, 1 ) + > {{alias}}( 3, 0.0, x1, 2, y1, 1 ) [ -2.0, 0.0, -1.0 ] > y0 [ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ] + {{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY ) Computes the cumulative sum of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. @@ -112,8 +111,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float32}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 ) [ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/examples/index.js index 0e176b0a14f9..64d24e25349a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/examples/index.js @@ -18,20 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float32Array = require( '@stdlib/array/float32' ); var scusumpw = require( './../lib' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); +var y = new Float32Array( x.length ); -x = new Float32Array( 10 ); -y = new Float32Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' + + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @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, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, sum, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); + + stdlib_strided_scusumpw( N, sum, X, strideX, Y, strideY ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/src/addon.cpp b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/src/addon.cpp deleted file mode 100644 index 6cb8c89e466f..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/src/addon.cpp +++ /dev/null @@ -1,164 +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/blas/ext/base/scusumpw.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_scusumpw { - - /** - * Computes the cumulative sum of single-precision floating-point strided array elements using pairwise summation. - * - * ## Notes - * - * - When called from JavaScript, the function expects six arguments: - * - * - `N`: number of indexed elements - * - `sum`: initial sum - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: output array - * - `strideY`: `Y` stride length - */ - napi_value node_scusumpw( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 6; - napi_value argv[ 6 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 6 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - bool res4; - status = napi_is_typedarray( env, argv[ 4 ], &res4 ); - assert( status == napi_ok ); - if ( res4 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype5; - status = napi_typeof( env, argv[ 5 ], &vtype5 ); - assert( status == napi_ok ); - if ( vtype5 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double sum; - status = napi_get_value_double( env, argv[ 1 ], &sum ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 5 ], &strideY ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_typedarray_type vtype4; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype4 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - stdlib_strided_scusumpw( N, (float)sum, (float *)X, strideX, (float *)Y, strideY ); - - return nullptr; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_scusumpw, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_scusumpw diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.js index 8f4b774d068a..b72e1617dde9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.js @@ -141,7 +141,7 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns output array unchanged', function test( t ) { var expected; var x; var y; @@ -152,10 +152,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumpw( -1, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumpw( 0, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.native.js index 5b481f1bfc2f..aae46fd36e56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -150,7 +149,7 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns output array unchanged', opts, function test( t ) { var expected; var x; var y; @@ -161,10 +160,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumpw( -1, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumpw( 0, 0.0, x, 1, 0, y, 1, 0 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -277,7 +276,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { tape( 'the function supports an `x` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -301,9 +299,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - scusumpw( N, 0.0, x, 2, 1, y, 1, 0 ); + scusumpw( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float32Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -313,7 +310,6 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { tape( 'the function supports a `y` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -337,9 +333,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - scusumpw( N, 0.0, x, 1, 0, y, 2, 1 ); + scusumpw( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float32Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.js index b1a31f637e07..ab929b774d78 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var scusumpw = require( './../lib/scusumpw.js' ); @@ -141,7 +140,7 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns output array unchanged', function test( t ) { var expected; var x; var y; @@ -152,10 +151,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumpw( -1, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumpw( 0, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -304,7 +303,6 @@ tape( 'the function supports view offsets', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float32Array([ @@ -328,9 +326,7 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - scusumpw( N, 0.0, x1, -2, y1, 1 ); + scusumpw( 3, 0.0, x1, -2, y1, 1 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.native.js index a37a8aaf8619..38fe431978f3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/scusumpw/test/test.scusumpw.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -150,7 +149,7 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', opts, function test( t ) { +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the output array unchanged', opts, function test( t ) { var expected; var x; var y; @@ -161,10 +160,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu expected = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); scusumpw( -1, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); scusumpw( 0, 0.0, x, 1, y, 1 ); - t.deepEqual( y, expected, 'returns `y` unchanged' ); + t.deepEqual( y, expected, 'returns expected value' ); t.end(); }); @@ -313,7 +312,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float32Array([ @@ -337,9 +335,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - scusumpw( N, 0.0, x1, -2, y1, 1 ); + scusumpw( 3, 0.0, x1, -2, y1, 1 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/srev/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/srev/manifest.json index 44daf08b843f..8d202bab4299 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/srev/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/srev/manifest.json @@ -1,5 +1,7 @@ { - "options": {}, + "options": { + "task": "build" + }, "fields": [ { "field": "src", @@ -24,6 +26,7 @@ ], "confs": [ { + "task": "build", "src": [ "./src/srev.c" ], @@ -40,6 +43,34 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array" ] + }, + { + "task": "benchmark", + "src": [ + "./src/srev.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/srev.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/manifest.json index 80ed912160b1..64bee9f734e5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/manifest.json @@ -1,5 +1,7 @@ { - "options": {}, + "options": { + "task": "build" + }, "fields": [ { "field": "src", @@ -24,6 +26,7 @@ ], "confs": [ { + "task": "build", "src": [ "./src/ssumkbn.c" ], @@ -40,6 +43,34 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array" ] + }, + { + "task": "benchmark", + "src": [ + "./src/ssumkbn.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/ssumkbn.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/src/addon.c index 9e9eb48f64b8..92fad314939d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/src/addon.c @@ -39,7 +39,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); napi_value v; - napi_status status = napi_create_double( env, (double)stdlib_strided_ssumkbn( N, (float *)X, stride ), &v ); + napi_status status = napi_create_double( env, (double)stdlib_strided_ssumkbn( N, X, stride ), &v ); assert( status == napi_ok ); return v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumors/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ssumors/manifest.json index 3b8d23a2712c..bac5eaeb4351 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumors/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumors/manifest.json @@ -1,5 +1,7 @@ { - "options": {}, + "options": { + "task": "build" + }, "fields": [ { "field": "src", @@ -24,6 +26,7 @@ ], "confs": [ { + "task": "build", "src": [ "./src/ssumors.c" ], @@ -35,11 +38,39 @@ ], "libpath": [], "dependencies": [ - "stdlib/napi/export.h", - "stdlib/napi/argv.h", - "stdlib/napi/argv_int64.h", - "stdlib/napi/argv_strided_float32array.h" + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" ] + }, + { + "task": "benchmark", + "src": [ + "./src/ssumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/ssumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] } ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumors/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ssumors/src/addon.c index 5555e3ea73e1..0a5df0031a98 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumors/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumors/src/addon.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "stdlib/blas/base/ssumors.h" +#include "stdlib/blas/ext/base/ssumors.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" @@ -39,7 +39,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); napi_value v; - napi_status status = napi_create_double( env, (double)stdlib_strided_ssumors( N, (float *)X, stride ), &v ); + napi_status status = napi_create_double( env, (double)stdlib_strided_ssumors( N, X, stride ), &v ); assert( status == napi_ok ); return v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json index 0291c43d5b4e..92cb2fbd64fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json @@ -1,45 +1,76 @@ { - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/ssumpw.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "stdlib/napi/export.h", - "stdlib/napi/argv.h", - "stdlib/napi/argv_int64.h", - "stdlib/napi/argv_strided_float32array.h" - ] - } - ] + "options": { + "task": "build" + }, + "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", + "src": [ + "./src/ssumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/ssumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/ssumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c index b53060ca3dd9..60ee16c25d1c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c @@ -39,7 +39,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); napi_value v; - napi_status status = napi_create_double( env, (double)stdlib_strided_ssumpw( N, (float *)X, stride ), &v ); + napi_status status = napi_create_double( env, (double)stdlib_strided_ssumpw( N, X, stride ), &v ); assert( status == napi_ok ); return v; diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/README.md b/lib/node_modules/@stdlib/constants/float32/half-pi/README.md new file mode 100644 index 000000000000..6c0af23e7fa1 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/README.md @@ -0,0 +1,123 @@ + + +# FLOAT32_HALF_PI + +> One half times the mathematical constant [π][pi]. + +
+ +## Usage + +```javascript +var FLOAT32_HALF_PI = require( '@stdlib/constants/float32/half-pi' ); +``` + +#### FLOAT32_HALF_PI + +One half times the mathematical constant [π][pi]. + +```javascript +var bool = ( FLOAT32_HALF_PI === 1.5707963705062866 ); +// returns true +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var FLOAT32_HALF_PI = require( '@stdlib/constants/float32/half-pi' ); + +console.log( FLOAT32_HALF_PI ); +// => 1.5707963705062866 +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float32/half_pi.h" +``` + +#### STDLIB_CONSTANT_FLOAT32_HALF_PI + +Macro for one half times the mathematical constant [π][pi]. + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/docs/repl.txt b/lib/node_modules/@stdlib/constants/float32/half-pi/docs/repl.txt new file mode 100644 index 000000000000..7b3e0c732a3d --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/docs/repl.txt @@ -0,0 +1,12 @@ + +{{alias}} + One half times the mathematical constant `π`. + + Examples + -------- + > {{alias}} + 1.5707963705062866 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/docs/types/index.d.ts b/lib/node_modules/@stdlib/constants/float32/half-pi/docs/types/index.d.ts new file mode 100644 index 000000000000..5d78da0f3012 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/docs/types/index.d.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* One half times the mathematical constant `π`. +* +* @example +* var val = FLOAT32_HALF_PI; +* // returns 1.5707963705062866 +*/ +declare const FLOAT32_HALF_PI: number; + + +// EXPORTS // + +export = FLOAT32_HALF_PI; diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/docs/types/test.ts b/lib/node_modules/@stdlib/constants/float32/half-pi/docs/types/test.ts new file mode 100644 index 000000000000..3dccf5e60016 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import FLOAT32_HALF_PI = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT32_HALF_PI; // $ExpectType number +} diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/examples/index.js b/lib/node_modules/@stdlib/constants/float32/half-pi/examples/index.js new file mode 100644 index 000000000000..7e5da5833d46 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/examples/index.js @@ -0,0 +1,24 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var FLOAT32_HALF_PI = require( './../lib' ); + +console.log( FLOAT32_HALF_PI ); +// => 1.5707963705062866 diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/include/stdlib/constants/float32/half_pi.h b/lib/node_modules/@stdlib/constants/float32/half-pi/include/stdlib/constants/float32/half_pi.h new file mode 100644 index 000000000000..8b7089769cee --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/include/stdlib/constants/float32/half_pi.h @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_CONSTANTS_FLOAT32_HALF_PI_H +#define STDLIB_CONSTANTS_FLOAT32_HALF_PI_H + +/** +* Macro for one half times the mathematical constant π. +*/ +#define STDLIB_CONSTANT_FLOAT32_HALF_PI 1.5707963267948966f + +#endif // !STDLIB_CONSTANTS_FLOAT32_HALF_PI_H diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/lib/index.js b/lib/node_modules/@stdlib/constants/float32/half-pi/lib/index.js new file mode 100644 index 000000000000..6e6856c41bbd --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/lib/index.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* One half times the mathematical constant `π`. +* +* @module @stdlib/constants/float32/half-pi +* @type {number} +* +* @example +* var FLOAT32_HALF_PI = require( '@stdlib/constants/float32/half-pi' ); +* // returns 1.5707963705062866 +*/ + +// MODULES // + +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* One half times the mathematical constant `π`. +* +* @constant +* @type {number} +* @default 1.5707963705062866 +* @see [Wikipedia]{@link https://en.wikipedia.org/wiki/Pi} +*/ +var FLOAT32_HALF_PI = float64ToFloat32( 1.5707963267948966 ); + + +// EXPORTS // + +module.exports = FLOAT32_HALF_PI; diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/manifest.json b/lib/node_modules/@stdlib/constants/float32/half-pi/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/package.json b/lib/node_modules/@stdlib/constants/float32/half-pi/package.json new file mode 100644 index 000000000000..d9de8e2c135a --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/constants/float32/half-pi", + "version": "0.0.0", + "description": "1/2 times π.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "constant", + "const", + "mathematics", + "math", + "half", + "pi", + "ieee754", + "float", + "floating-point", + "float32" + ] +} diff --git a/lib/node_modules/@stdlib/constants/float32/half-pi/test/test.js b/lib/node_modules/@stdlib/constants/float32/half-pi/test/test.js new file mode 100644 index 000000000000..f8f16eae933d --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/half-pi/test/test.js @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var FLOAT32_HALF_PI = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT32_HALF_PI, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'export is a single-precision floating-point number equal to 1.5707963705062866', function test( t ) { + t.equal( FLOAT32_HALF_PI, float64ToFloat32( 1.5707963267948966 ), 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/iter/do-until-each/package.json b/lib/node_modules/@stdlib/iter/do-until-each/package.json index 930b47f0f321..85db59837c85 100644 --- a/lib/node_modules/@stdlib/iter/do-until-each/package.json +++ b/lib/node_modules/@stdlib/iter/do-until-each/package.json @@ -1,68 +1,67 @@ { - "name": "@stdlib/iter/until-each", - "version": "0.0.0", - "description": "Create an iterator which, while a test condition is false, invokes a function for each iterated value before returning the iterated value.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/iter/until-each", + "version": "0.0.0", + "description": "Create an iterator which, while a test condition is false, invokes a function for each iterated value before returning the iterated value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { "name": "The Stdlib Authors", "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdutils", - "stdutil", - "utilities", - "utility", - "utils", - "util", - "do-until-each", - "dountileach", - "until", - "each", - "iterator", - "iterable", - "iterate" - ] - } - \ No newline at end of file + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdutils", + "stdutil", + "utilities", + "utility", + "utils", + "util", + "do-until-each", + "dountileach", + "until", + "each", + "iterator", + "iterable", + "iterate" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/assert/int32-is-odd/README.md b/lib/node_modules/@stdlib/math/base/assert/int32-is-odd/README.md index 0e0a7140be7a..2f4f79387df4 100644 --- a/lib/node_modules/@stdlib/math/base/assert/int32-is-odd/README.md +++ b/lib/node_modules/@stdlib/math/base/assert/int32-is-odd/README.md @@ -81,6 +81,98 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/assert/int32_is_odd.h" +``` + +#### stdlib_base_int32_is_odd( x ) + +Tests if a 32-bit integer is odd. + +```c +#include + +bool out = stdlib_base_int32_is_odd( 5 ); +// returns true + +out = stdlib_base_int32_is_odd( -2 ); +// returns false +``` + +The function accepts the following arguments: + +- **x**: `[in] int32_t` input value. + +```c +bool stdlib_base_int32_is_odd( const int32_t x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/assert/int32_is_odd.h" +#include +#include +#include + +int main( void ) { + const int32_t x[] = { 5, -5, 3, -3, 0, 2 }; + + bool b; + int i; + for ( i = 0; i < 5; i++ ) { + b = stdlib_base_int32_is_odd( x[ i ] ); + printf( "Value: %d. int32 Is Odd? %s.\n", x[ i ], ( b ) ? "True" : "False" ); + } +} +``` + +
+ + + +
+ + +