From 9e81f435cb03196d1e15f769e8d2744a1d8a91ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 03:46:11 +0000 Subject: [PATCH] Auto-generated commit --- .github/.keepalive | 1 + .github/workflows/benchmark.yml | 6 +- .github/workflows/cancel.yml | 3 +- .github/workflows/close_pull_requests.yml | 36 +- .github/workflows/examples.yml | 10 +- .github/workflows/npm_downloads.yml | 12 +- .github/workflows/productionize.yml | 42 +- .github/workflows/publish.yml | 15 +- .github/workflows/test.yml | 9 +- .github/workflows/test_bundles.yml | 27 +- .github/workflows/test_coverage.yml | 15 +- .github/workflows/test_install.yml | 9 +- README.md | 4 +- package.json | 2 +- test/dist/test.js | 1021 +++++++++++++++++++++ 15 files changed, 1146 insertions(+), 66 deletions(-) create mode 100644 .github/.keepalive create mode 100644 test/dist/test.js diff --git a/.github/.keepalive b/.github/.keepalive new file mode 100644 index 0000000..46100a3 --- /dev/null +++ b/.github/.keepalive @@ -0,0 +1 @@ +2023-10-01T03:46:08.011Z diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 06a9a75..ab56cca 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -41,11 +41,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml index a00dbe5..3acd3a9 100644 --- a/.github/workflows/cancel.yml +++ b/.github/workflows/cancel.yml @@ -44,7 +44,8 @@ jobs: # Cancel existing workflow runs: - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 + # Pin action to full length commit SHA corresponding to v0.11.0 + uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 with: workflow_id: >- benchmark.yml, diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml index fa8d972..00d64cf 100644 --- a/.github/workflows/close_pull_requests.yml +++ b/.github/workflows/close_pull_requests.yml @@ -26,19 +26,29 @@ on: # Workflow jobs: jobs: + + # Define job to close all pull requests: run: + + # Define the type of virtual host machine on which to run the job: runs-on: ubuntu-latest + + # Define the sequence of job steps... steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/pow) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file + + # Close pull request + - name: 'Close pull request' + # Pin action to full length commit SHA corresponding to v3.1.2 + uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 + with: + comment: | + Thank you for submitting a pull request. :raised_hands: + + We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). + + We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/pow) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. + + Thank you again, and we look forward to receiving your contribution! :smiley: + + Best, + The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 7902a7d..c1c45e7 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -39,13 +39,15 @@ jobs: # Define the sequence of job steps... steps: - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 + # Checkout repository: + - name: 'Checkout repository' + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml index 7ce6d1a..b0509ab 100644 --- a/.github/workflows/npm_downloads.yml +++ b/.github/workflows/npm_downloads.yml @@ -45,12 +45,14 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 timeout-minutes: 10 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -84,7 +86,8 @@ jobs: # Upload the download data: - name: 'Upload data' - uses: actions/upload-artifact@v3 + # Pin action to full length commit SHA corresponding to v3.1.3 + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 with: # Define a name for the uploaded artifact (ensuring a unique name for each job): name: npm_downloads @@ -99,7 +102,8 @@ jobs: # Send data to events server: - name: 'Post data' - uses: distributhor/workflow-webhook@v3 + # Pin action to full length commit SHA corresponding to v3.0.3: + uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 env: webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml index 91f2b93..265afda 100644 --- a/.github/workflows/productionize.yml +++ b/.github/workflows/productionize.yml @@ -61,13 +61,15 @@ jobs: steps: # Checkout main branch of repository: - name: 'Checkout main branch' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: main # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -132,7 +134,8 @@ jobs: # Checkout the repository: - name: 'Checkout repository' if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: # Use the `production` branch: ref: production @@ -140,7 +143,8 @@ jobs: # Install Node.js: - name: 'Install Node.js' if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -184,7 +188,8 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Configure git: - name: 'Configure git' @@ -251,7 +256,8 @@ jobs: # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -334,7 +340,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -357,7 +364,8 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Configure git: - name: 'Configure git' @@ -416,7 +424,8 @@ jobs: # Install Node.js - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -505,7 +514,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -528,7 +538,8 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Configure git: - name: 'Configure git' @@ -595,7 +606,8 @@ jobs: # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -682,7 +694,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -706,7 +719,8 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: fetch-depth: 2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 474004b..b17435b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -61,11 +61,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -197,7 +199,8 @@ jobs: # Publish package to npm: - name: 'Publish package to npm' - uses: JS-DevTools/npm-publish@v2 + # Pin action to full length commit SHA corresponding to v2.2.2 + uses: JS-DevTools/npm-publish@fe72237be0920f7a0cafd6a966c9b929c9466e9b with: token: ${{ secrets.NPM_TOKEN }} access: public @@ -209,7 +212,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -230,7 +234,8 @@ jobs: # Cancel any running or queued workflow runs: - name: 'Cancel running or queued workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 + # Pin action to full length commit SHA corresponding to v0.11.0 + uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 with: workflow_id: >- benchmark.yml, diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9963215..d301ee1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,11 +58,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -89,7 +91,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} diff --git a/.github/workflows/test_bundles.yml b/.github/workflows/test_bundles.yml index 172cb2d..0d26143 100644 --- a/.github/workflows/test_bundles.yml +++ b/.github/workflows/test_bundles.yml @@ -49,13 +49,15 @@ jobs: steps: # Checkout UMD branch of the repository: - name: 'Checkout branch with UMD build' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: umd # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 17 @@ -88,7 +90,8 @@ jobs: # Send notification to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -113,13 +116,15 @@ jobs: # Checkout ES modules branch of the repository: - name: 'Checkout branch with ESM build' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: esm # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 17 @@ -130,7 +135,8 @@ jobs: # Send notification to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -155,13 +161,15 @@ jobs: # Checkout Deno branch of the repository: - name: 'Checkout branch with Deno build' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: deno # Install Deno: - name: 'Install Deno' - uses: denoland/setup-deno@v1 + # Pin action to full length commit SHA corresponding to v1.1.2 + uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 with: deno-version: vx.x.x @@ -172,7 +180,8 @@ jobs: # Send notification to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml index a73c515..5b2b1ea 100644 --- a/.github/workflows/test_coverage.yml +++ b/.github/workflows/test_coverage.yml @@ -46,11 +46,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -77,7 +79,8 @@ jobs: # Upload coverage report to Codecov: - name: 'Upload coverage to Codecov' id: upload - uses: codecov/codecov-action@v3 + # Pin action to full length commit SHA corresponding to v3.1.4 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d with: directory: reports/coverage flags: unittests @@ -106,7 +109,8 @@ jobs: # Send Slack notification if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -115,7 +119,8 @@ jobs: # Send data to events server: - name: 'Post data' - uses: distributhor/workflow-webhook@v3 + # Pin action to full length commit SHA corresponding to v3.0.3: + uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 env: webhook_url: ${{ secrets.STDLIB_COVERAGE_URL }} webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 1c8f9ff..309aa4c 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -58,11 +58,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -75,7 +77,8 @@ jobs: # Send Slack notification if job fails: - name: 'Send notification to Slack in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} diff --git a/README.md b/README.md index 6cd2ce4..0f3086c 100644 --- a/README.md +++ b/README.md @@ -193,8 +193,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-special-pow.svg [npm-url]: https://npmjs.org/package/@stdlib/math-base-special-pow -[test-image]: https://github.com/stdlib-js/math-base-special-pow/actions/workflows/test.yml/badge.svg?branch=v0.1.0 -[test-url]: https://github.com/stdlib-js/math-base-special-pow/actions/workflows/test.yml?query=branch:v0.1.0 +[test-image]: https://github.com/stdlib-js/math-base-special-pow/actions/workflows/test.yml/badge.svg?branch=main +[test-url]: https://github.com/stdlib-js/math-base-special-pow/actions/workflows/test.yml?query=branch:main [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-special-pow/main.svg [coverage-url]: https://codecov.io/github/stdlib-js/math-base-special-pow?branch=main diff --git a/package.json b/package.json index 1dc6d8f..7f7c8c8 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@stdlib/math-base-assert-is-positive-zero": "^0.1.0", "@stdlib/math-base-special-round": "^0.1.0", "@stdlib/math-base-tools-evalpoly-compile": "^0.1.0", - "@stdlib/random-base-randu": "^0.0.8", + "@stdlib/random-base-randu": "^0.1.0", "@stdlib/time-current-year": "^0.1.0", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", diff --git a/test/dist/test.js b/test/dist/test.js new file mode 100644 index 0000000..e0acbff --- /dev/null +++ b/test/dist/test.js @@ -0,0 +1,1021 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var abs = require( '@stdlib/math-base-special-abs' ); +var sqrt = require( '@stdlib/math-base-special-sqrt' ); +var randu = require( '@stdlib/random-base-randu' ); +var round = require( '@stdlib/math-base-special-round' ); +var PINF = require( '@stdlib/constants-float64-pinf' ); +var NINF = require( '@stdlib/constants-float64-ninf' ); +var EPS = require( '@stdlib/constants-float64-eps' ); +var MAX_SAFE_INTEGER = require( '@stdlib/constants-float64-max-safe-integer' ); +var isnan = require( '@stdlib/math-base-assert-is-nan' ); +var isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' ); +var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' ); +var pow = require( './../../dist' ); + + +// FIXTURES // + +var squaredSmall = require( './../..xtures/julia/squared_small.json' ); +var squaredLarge = require( './../..xtures/julia/squared_large.json' ); +var cubedSmall = require( './../..xtures/julia/cubed_small.json' ); +var cubedLarge = require( './../..xtures/julia/cubed_large.json' ); +var toTheFourthSmall = require( './../..xtures/julia/to_the_fourth_small.json' ); +var toTheFourthLarge = require( './../..xtures/julia/to_the_fourth_large.json' ); +var baseNearUnitySmall = require( './../..xtures/julia/base_near_unity_small.json' ); +var baseNearUnityLarge = require( './../..xtures/julia/base_near_unity_large.json' ); +var baseNearUnityHuge = require( './../..xtures/julia/base_near_unity_huge.json' ); +var subnormalResults = require( './../..xtures/julia/subnormal_results.json' ); +var negativeExpSmallSmall = require( './../..xtures/julia/negative_exp_small_small.json' ); +var negativeExpSmallLarge = require( './../..xtures/julia/negative_exp_small_large.json' ); +var negativeExpLargeSmall = require( './../..xtures/julia/negative_exp_large_small.json' ); +var negativeExpLargeLarge = require( './../..xtures/julia/negative_exp_large_large.json' ); +var smallSmall = require( './../..xtures/julia/small_small.json' ); +var smallLarge = require( './../..xtures/julia/small_large.json' ); +var largeSmall = require( './../..xtures/julia/large_small.json' ); +var decimalDecimal = require( './../..xtures/julia/decimal_decimal.json' ); +var decimalInteger = require( './../..xtures/julia/decimal_integer.json' ); +var integerDecimal = require( './../..xtures/julia/integer_decimal.json' ); +var integerInteger = require( './../..xtures/julia/integer_integer.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof pow, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function accepts two parameters: a base and an exponent', function test( t ) { + t.equal( pow.length, 2.0, 'arity is 2' ); + t.end(); +}); + +tape( 'the function evaluates the exponential function (`y = 2` and `x` small)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = squaredSmall.x; + y = squaredSmall.y; + expected = squaredSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`y = 2` and `x` large)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = squaredLarge.x; + y = squaredLarge.y; + expected = squaredLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`y = 3` and `x` small)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = cubedSmall.x; + y = cubedSmall.y; + expected = cubedSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`y = 3` and `x` large)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = cubedLarge.x; + y = cubedLarge.y; + expected = cubedLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`y = 4` and `x` small)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = toTheFourthSmall.x; + y = toTheFourthSmall.y; + expected = toTheFourthSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`y = 4` and `x` large)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = toTheFourthLarge.x; + y = toTheFourthLarge.y; + expected = toTheFourthLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`x ~ 1`, `y` small)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = baseNearUnitySmall.x; + y = baseNearUnitySmall.y; + expected = baseNearUnitySmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`x ~ 1`, `y` large)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = baseNearUnityLarge.x; + y = baseNearUnityLarge.y; + expected = baseNearUnityLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (`x ~ 1`, `y` huge)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = baseNearUnityHuge.x; + y = baseNearUnityHuge.y; + expected = baseNearUnityHuge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (subnormal results)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = subnormalResults.x; + y = subnormalResults.y; + expected = subnormalResults.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (negative exponents; `x` small, `y` small)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = negativeExpSmallSmall.x; + y = negativeExpSmallSmall.y; + expected = negativeExpSmallSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + if ( expected[i] === null ) { + t.equal( actual, PINF, 'pow('+x[i]+','+y[i]+') returns +infinity' ); + } else { + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (negative exponents; `x` small, `y` large)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = negativeExpSmallLarge.x; + y = negativeExpSmallLarge.y; + expected = negativeExpSmallLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + if ( expected[i] === null ) { + t.equal( actual, PINF, 'pow('+x[i]+','+y[i]+') returns +infinity' ); + } else { + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (negative exponents; `x` large, `y` small)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = negativeExpLargeSmall.x; + y = negativeExpLargeSmall.y; + expected = negativeExpLargeSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + if ( expected[i] === null ) { + t.equal( actual, PINF, 'pow('+x[i]+','+y[i]+') returns +infinity' ); + } + else if ( expected[i] === 5.0e-324 ) { + // Julia, Python, and R occasionally return the min subnormal value, when, in fact, the result should underflow; e.g., `pow(571413458040000, -21.92803603935001)` returns `0` for this implementation, and `5.0e-324` on other platforms. The answer checked on Wolfram Alpha is `2.564828778186e-324`, which is less than the min subnormal. This discrepancy arises, at least when compared to Julia's Openlibm, due to differences in our `ldexp` and their `scalbn`. + t.equal( actual === expected[i] || actual === 0.0, true, 'pow('+x[i]+','+y[i]+') returns '+expected[i]+' or 0' ); + } + else { + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (negative exponents; `x` large, `y` large)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = negativeExpLargeLarge.x; + y = negativeExpLargeLarge.y; + expected = negativeExpLargeLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + if ( expected[i] === null ) { + t.equal( actual, PINF, 'pow('+x[i]+','+y[i]+') returns +infinity' ); + } else { + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (near overflow)', function test( t ) { + var x; + var y; + var v; + + x = 2.0; + y = 1024; + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + x = 2.0; + y = 1023; + v = pow( x, y ); + t.equal( v, 8.98846567431158e307, 'pow('+x+','+y+') returns 8.98846567431158e307' ); + + x = 2.001355585648339; + y = 1023; + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + x = 2.0; + y = 1025; + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + x = 1.998647974895499; + y = 1025; + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + x = 2.0 + ( EPS*2.0 ); + y = 1024; + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + t.end(); +}); + +tape( 'the function evaluates the exponential function (near underflow)', function test( t ) { + var x; + var y; + var v; + + x = 2.0; + y = -1075; + v = pow( x, y ); + t.equal( v, 0.0, 'pow('+x+','+y+') returns 0' ); + + x = 1.9987108395124398; + y = -1075; + v = pow( x, y ); + t.equal( v, 5.0e-324, 'pow('+x+','+y+') returns 5e-324' ); + + // Wolfram Alpha: 2.47032822920649828116748364864574508116622553173015e-324 + x = 1.9999999999999998; + y = -1075; + v = pow( x, y ); + t.equal( v, 0.0, 'pow('+x+','+y+') returns 0' ); + + x = 1.9999999999999999; + y = -1075; + v = pow( x, y ); + t.equal( v, 0.0, 'pow('+x+','+y+') returns 0' ); + + t.end(); +}); + +tape( 'the function evaluates the exponential function (small `x`, large `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = smallLarge.x; + y = smallLarge.y; + expected = smallLarge.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + if ( expected[i] === 5.0e-324 ) { + t.equal( actual === expected[i] || actual === 0.0, true, 'pow('+x[i]+','+y[i]+') returns 5e-324 or 0' ); + } else { + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (large `x`, small `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = largeSmall.x; + y = largeSmall.y; + expected = largeSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (small `x`, small `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = smallSmall.x; + y = smallSmall.y; + expected = smallSmall.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (decimal `x`, decimal `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = decimalDecimal.x; + y = decimalDecimal.y; + expected = decimalDecimal.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (decimal `x`, integer `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = decimalInteger.x; + y = decimalInteger.y; + expected = decimalInteger.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (integer `x`, decimal `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = integerDecimal.x; + y = integerDecimal.y; + expected = integerDecimal.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function evaluates the exponential function (integer `x`, integer `y`)', function test( t ) { + var expected; + var actual; + var x; + var y; + var i; + + x = integerInteger.x; + y = integerInteger.y; + expected = integerInteger.expected; + for ( i = 0; i < x.length; i++ ) { + actual = pow( x[i], y[i] ); + t.equal( actual, expected[i], 'pow('+x[i]+','+y[i]+') returns '+expected[i] ); + } + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN` for the exponent', function test( t ) { + var v; + + v = pow( -3.0, NaN ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = pow( 0.0, NaN ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN` for the base', function test( t ) { + var v; + + v = pow( NaN, 5.0 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = pow( NaN, 1.0 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = pow( NaN, 0.0 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'any number raised to the zero power is `1`', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + x = ( randu()*1.0e6 ) - 5.0e5; + v = pow( x, 0.0 ); + t.equal( v, 1.0, 'pow('+x+',0.0) returns 1' ); + } + t.equal( pow( PINF, 0.0 ), 1.0, 'inf^0 = 1' ); + t.equal( pow( NINF, 0.0 ), 1.0, '(-inf)^0 = 1' ); + t.equal( pow( 0.0, 0.0 ), 1.0, '0^0 = 1' ); + t.end(); +}); + +tape( 'any number raised to the `-1` power is the reciprocal of that number', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + x = ( randu()*1.0e6 ) - 5.0e5; + v = pow( x, -1.0 ); + t.equal( v, 1/x, 'pow('+x+',0.0) returns '+(1/x) ); + } + t.equal( isPositiveZero( pow( PINF, -1.0 ) ), true, 'inf^-1 = 0' ); + t.equal( isNegativeZero( pow( NINF, -1.0 ) ), true, '(-inf)^0 = -0' ); + t.equal( pow( 0.0, -1.0 ), PINF, '0^-1 = +infinity' ); + t.equal( pow( -0.0, -1.0 ), NINF, '(-0)^-1 = -infinity' ); + t.end(); +}); + +tape( 'unity raised to any power is `1`', function test( t ) { + var y; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + y = ( randu()*1.0e6 ) - 5.0e5; + v = pow( 1.0, y ); + t.equal( v, 1.0, 'pow(1.0,'+y+') returns 1' ); + } + t.equal( pow( 1.0, PINF ), 1.0, '1^inf = 1' ); + t.equal( pow( 1.0, NINF ), 1.0, '1^(-inf) = 1' ); + t.equal( pow( 1.0, 0.0 ), 1.0, '1^0 = 1' ); + t.end(); +}); + +tape( '`-1` raised to any odd integer is `-1`', function test( t ) { + var v; + var i; + for ( i = -51; i < 53; i += 2 ) { + v = pow( -1.0, i ); + t.equal( v, -1.0, 'pow(1.0,'+i+') returns -1' ); + } + t.end(); +}); + +tape( '`+-0` raised to `-infinity` is `+infinity`', function test( t ) { + var v; + + v = pow( +0.0, NINF ); + t.equal( v, PINF, 'returns +infinity' ); + + v = pow( -0.0, NINF ); + t.equal( v, PINF, 'returns +infinity' ); + + t.end(); +}); + +tape( '`+-0` raised to `+infinity` is `0`', function test( t ) { + var v; + + v = pow( +0.0, PINF ); + t.equal( isPositiveZero( v ), true, 'returns +0' ); + + v = pow( -0.0, PINF ); + t.equal( isPositiveZero( v ), true, 'returns +0' ); + + t.end(); +}); + +tape( '`+-0` raised to any positive finite number which is not an odd integer is `0`', function test( t ) { + var y; + var i; + var v; + + y = [ + 2, + 3.14, + 1.0e5, + 5.1, + 9.999999 + ]; + + for ( i = 0; i < y.length; i++ ) { + v = pow( +0.0, y[ i ] ); + t.equal( isPositiveZero( v ), true, 'pow(0,'+y[i]+') returns +0' ); + + v = pow( -0.0, y[ i ] ); + t.equal( isPositiveZero( v ), true, 'pow(-0,'+y[i]+') returns +0' ); + } + t.end(); +}); + +tape( '`+-0` raised to any positive odd integer is `+-0`', function test( t ) { + var i; + var v; + + for ( i = 1; i < 101; i += 2 ) { + v = pow( +0.0, i ); + t.equal( isPositiveZero( v ), true, 'pow(0,'+i+') returns +0' ); + + v = pow( -0.0, i ); + t.equal( isNegativeZero( v ), true, 'pow(-0,'+i+') returns -0' ); + } + t.end(); +}); + +tape( '`+-0` raised to any negative finite number which is not an odd integer is `+infinity`', function test( t ) { + var y; + var i; + var v; + + y = [ + -2, + -3.14, + -1.0e5, + -5.1, + -9.999999 + ]; + + for ( i = 0; i < y.length; i++ ) { + v = pow( +0.0, y[ i ] ); + t.equal( v, PINF, 'pow(0,'+y[i]+') returns +infinity' ); + + v = pow( -0.0, y[ i ] ); + t.equal( v, PINF, 'pow(-0,'+y[i]+') returns +infinity' ); + } + t.end(); +}); + +tape( '`+-0` raised to any negative odd integer is `+-infinity`', function test( t ) { + var i; + var v; + + for ( i = -101; i < 0; i += 2 ) { + v = pow( +0.0, i ); + t.equal( v, PINF, 'pow(0,'+i+') returns +infinity' ); + + v = pow( -0.0, i ); + t.equal( v, NINF, 'pow(-0,'+i+') returns -infinity' ); + } + t.end(); +}); + +tape( '`-1` raised to `+-infinity` is indeterminate and the function returns `NaN`', function test( t ) { + var v; + + v = pow( -1.0, PINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = pow( -1.0, NINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'raising any number to the `1/2` power returns the same results as evaluating the principal square root', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 500; i++ ) { + x = randu()*1.0e5; + v = pow( x, 0.5 ); + t.equal( v, sqrt( x ), 'returns sqrt('+x+')' ); + } + t.end(); +}); + +tape( 'raising any number to the `-1/2` power returns the same results as evaluating the inverse of the principal square root', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 500; i++ ) { + x = randu()*1.0e5; + v = pow( x, -0.5 ); + t.equal( v, 1.0/sqrt( x ), 'returns sqrt('+x+')' ); + } + t.end(); +}); + +tape( 'the function returns `+infinity` if a positive number greater than `1` is raised to `+infinity`', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + x = 1.0 + ( randu()*1.0e5 ); + v = pow( x, PINF ); + t.equal( v, PINF, 'pow('+x+',+infinity) returns +infinity' ); + } + t.end(); +}); + +tape( 'the function returns `+infinity` if a negative number less than `-1` is raised to `+infinity`', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + x = ( -randu()*1.0e5 ) - 1.0; + v = pow( x, PINF ); + t.equal( v, PINF, 'pow('+x+',+infinity) returns +infinity' ); + } + t.end(); +}); + +tape( 'the function returns `+infinity` if `-infinity` is raised to `+infinity`', function test( t ) { + var v = pow( NINF, PINF ); + t.equal( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'the function returns `(-0)^y` if `-infinity` is raised to a numeric `y` power', function test( t ) { + var y; + var v; + var i; + + for ( i = 0; i < 100; i++ ) { + y = ( randu()*100.0 ) - 50.0; + v = pow( NINF, y ); + t.equal( v, pow( -0.0, -y ), 'pow(-infinity,'+y+') returns pow(-0,-'+y+')' ); + } + v = pow( NINF, NINF ); + t.equal( v, pow( -0.0, PINF ), 'pow(-infinity,-infinity) returns pow(-0,+infinity)' ); + + v = pow( NINF, PINF ); + t.equal( v, pow( -0.0, NINF ), 'pow(-infinity,+infinity) returns pow(-0,-infinity)' ); + + v = pow( NINF, 5.0 ); + t.equal( v, pow( -0.0, -5.0 ), 'pow(-infinity,5) returns pow(-0,-5)' ); + + v = pow( NINF, 2.0 ); + t.equal( v, pow( -0.0, -2.0 ), 'pow(-infinity,2) returns pow(-0,-2)' ); + + v = pow( NINF, -5.0 ); + t.equal( v, pow( -0.0, 5.0 ), 'pow(-infinity,-5) returns pow(-0,5)' ); + + v = pow( NINF, -2.0 ); + t.equal( v, pow( -0.0, 2.0 ), 'pow(-infinity,-2) returns pow(-0,2)' ); + + t.end(); +}); + +tape( 'the function returns `0` if a positive number greater than `1` is raised to `-infinity`', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + x = 1.0 + ( randu()*1.0e5 ); + v = pow( x, NINF ); + t.equal( v, 0.0, 'pow('+x+',-infinity) returns 0' ); + } + t.end(); +}); + +tape( 'the function returns `0` if `+infinity` is raised to `-infinity`', function test( t ) { + var v = pow( PINF, NINF ); + t.equal( v, 0.0, 'returns 0' ); + t.end(); +}); + +tape( 'the function returns `0` if `+infinity` is raised to any negative finite number', function test( t ) { + var y; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + y = -(randu() * 1.0e5) - EPS; + v = pow( PINF, y ); + t.equal( isPositiveZero( v ), true, 'returns 0' ); + } + t.end(); +}); + +tape( 'the function returns `+infinity` if `+infinity` is raised to any positive finite number', function test( t ) { + var y; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + y = ( randu()*1.0e5 ) + EPS; + v = pow( PINF, y ); + t.equal( v, PINF, 'returns +infinity' ); + } + t.end(); +}); + +tape( 'the function returns `0` if a negative number less than `-1` is raised to `-infinity`', function test( t ) { + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + x = ( -randu()*1.0e5 ) - 1.0; + v = pow( x, NINF ); + t.equal( v, 0.0, 'pow('+x+',-infinity) returns 0' ); + } + t.end(); +}); + +tape( 'the function returns `NaN` if asked to raise a negative number to an exponent whose absolute value is greater than 0 but less than 1', function test( t ) { + var x; + var y; + var v; + var i; + + for ( i = 0; i < 100; i++ ) { + x = ( -randu()*1.0e5 ) - EPS; + y = randu(); + if ( y === 0.0 || y === 1.0 ) { + continue; + } + v = pow( x, y ); + t.equal( isnan( v ), true, 'pow('+x+','+y+') returns NaN' ); + } + t.end(); +}); + +tape( 'if `y > 2^64` and `x` is greater than `1`, the function overflows', function test( t ) { + var x; + var y; + var v; + + x = 1.0 + EPS; // smallest value greater than 1.0 + y = 3.6893488147419103e19; // 2.0^65 + v = pow( x, y ); + t.equal( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'if `y < -(2^64)` and `x` is greater than `1`, the function underflows', function test( t ) { + var x; + var y; + var v; + + x = 1.0 + EPS; // smallest value greater than 1.0 + y = -3.6893488147419103e19; // -(2.0)^65 + v = pow( x, y ); + t.equal( v, 0.0, 'returns 0' ); + t.end(); +}); + +tape( 'if `y > 2^64` and `x` is less than `1`, the function underflows', function test( t ) { + var x; + var y; + var v; + + x = 1.0 - EPS; // greatest value less than 1.0 + y = 3.6893488147419103e19; // 2.0^65 + v = pow( x, y ); + t.equal( v, 0.0, 'returns 0' ); + t.end(); +}); + +tape( 'if `y < -(2^64)` and `x` is less than `1`, the function overflows', function test( t ) { + var x; + var y; + var v; + + x = 1.0 - EPS; // greatest value less than 1.0 + y = -3.6893488147419103e19; // -(2.0^65) + v = pow( x, y ); + t.equal( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'if `y > 2^31` and `|x|` significantly less than unity, the function underflows', function test( t ) { + var exp; + var x; + var y; + var v; + var i; + + for ( i = 0; i < 100; i++ ) { + x = 0.5 * randu(); + + exp = round( randu()*32.0 ) + 32; + y = pow( 2.0, exp ); + + v = pow( x, y ); + t.equal( isPositiveZero( v ), true, 'pow('+x+','+y+') returns +0' ); + + if ( y < MAX_SAFE_INTEGER ) { + y += 1; + v = pow( -x, y ); + t.equal( isNegativeZero( v ), true, 'pow(-'+x+','+y+') returns -0' ); + } + } + t.end(); +}); + +tape( 'if `y < -(2^31)` and `|x|` significantly less than unity, the function overflows', function test( t ) { + var exp; + var x; + var y; + var v; + var i; + + for ( i = 0; i < 100; i++ ) { + x = 0.5 * randu(); + + exp = round( randu()*32.0 ) + 32; + y = -pow( 2.0, exp ); + + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + if ( abs(y) < MAX_SAFE_INTEGER ) { + y -= 1; + v = pow( -x, y ); + t.equal( v, NINF, 'pow(-'+x+','+y+') returns -infinity' ); + } + } + t.end(); +}); + +tape( 'if `y < -(2^31)` and `|x|` significantly greater than unity, the function underflows', function test( t ) { + var exp; + var x; + var y; + var v; + var i; + + for ( i = 0; i < 100; i++ ) { + x = 2.0 + ( randu()*1.0e5 ); + + exp = round( randu()*32.0 ) + 32; + y = -pow( 2.0, exp ); + + v = pow( x, y ); + t.equal( isPositiveZero( v ), true, 'pow('+x+','+y+') returns +0' ); + + if ( abs(y) < MAX_SAFE_INTEGER ) { + y -= 1; + v = pow( -x, y ); + t.equal( isNegativeZero( v ), true, 'pow(-'+x+','+y+') returns -0' ); + } + } + t.end(); +}); + +tape( 'if `y > 2^31` and `|x|` significantly greater than unity, the function overflows', function test( t ) { + var exp; + var x; + var y; + var v; + var i; + + for ( i = 0; i < 100; i++ ) { + x = 2.0 + ( randu()*1.0e5 ); + + exp = round( randu()*32.0 ) + 32; + y = pow( 2.0, exp ); + + v = pow( x, y ); + t.equal( v, PINF, 'pow('+x+','+y+') returns +infinity' ); + + if ( y < MAX_SAFE_INTEGER ) { + y += 1; + v = pow( -x, y ); + t.equal( v, NINF, 'pow(-'+x+','+y+') returns -infinity' ); + } + } + t.end(); +});