diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b40f5ce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/linspace) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f28f6c1..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/linspace) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 54a276c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '10 10 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -346,7 +343,7 @@ console.log( out ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -409,19 +406,19 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-linspace/main/LICENSE -[@stdlib/math/base/special/roundn]: https://github.com/stdlib-js/math-base-special-roundn +[@stdlib/math/base/special/roundn]: https://github.com/stdlib-js/math-base-special-roundn/tree/esm -[@stdlib/array/typed-float-dtypes]: https://github.com/stdlib-js/array-typed-float-dtypes +[@stdlib/array/typed-float-dtypes]: https://github.com/stdlib-js/array-typed-float-dtypes/tree/esm -[@stdlib/array/typed-complex-dtypes]: https://github.com/stdlib-js/array-typed-complex-dtypes +[@stdlib/array/typed-complex-dtypes]: https://github.com/stdlib-js/array-typed-complex-dtypes/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/incrspace]: https://github.com/stdlib-js/array-incrspace +[@stdlib/array/incrspace]: https://github.com/stdlib-js/array-incrspace/tree/esm -[@stdlib/array/logspace]: https://github.com/stdlib-js/array-logspace +[@stdlib/array/logspace]: https://github.com/stdlib-js/array-logspace/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.assign.complex128_complex.length.js b/benchmark/benchmark.assign.complex128_complex.length.js deleted file mode 100644 index 2762596..0000000 --- a/benchmark/benchmark.assign.complex128_complex.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex128Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:assign:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.complex128_real.length.js b/benchmark/benchmark.assign.complex128_real.length.js deleted file mode 100644 index 5f47e8c..0000000 --- a/benchmark/benchmark.assign.complex128_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex128Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.complex64_complex.length.js b/benchmark/benchmark.assign.complex64_complex.length.js deleted file mode 100644 index 3ca75dd..0000000 --- a/benchmark/benchmark.assign.complex64_complex.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:assign:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.complex64_real.length.js b/benchmark/benchmark.assign.complex64_real.length.js deleted file mode 100644 index 9232104..0000000 --- a/benchmark/benchmark.assign.complex64_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.float32_real.length.js b/benchmark/benchmark.assign.float32_real.length.js deleted file mode 100644 index a4acd41..0000000 --- a/benchmark/benchmark.assign.float32_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Float32Array = require( '@stdlib/array-float32' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.float64_real.length.js b/benchmark/benchmark.assign.float64_real.length.js deleted file mode 100644 index 26ca28b..0000000 --- a/benchmark/benchmark.assign.float64_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.generic_complex.length.js b/benchmark/benchmark.assign.generic_complex.length.js deleted file mode 100644 index b22a935..0000000 --- a/benchmark/benchmark.assign.generic_complex.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.generic_real.length.js b/benchmark/benchmark.assign.generic_real.length.js deleted file mode 100644 index 6c0c2c9..0000000 --- a/benchmark/benchmark.assign.generic_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index 195876f..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,227 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::real:assign:dtype=float64', function benchmark( b ) { - var out; - var v; - var i; - - out = new Float64Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=float32', function benchmark( b ) { - var out; - var v; - var i; - - out = new Float32Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=generic', function benchmark( b ) { - var out; - var v; - var i; - - out = zeros( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:assign:dtype=generic', function benchmark( b ) { - var out; - var x1; - var x2; - var v; - var i; - - out = zeros( 10 ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=complex128', function benchmark( b ) { - var out; - var v; - var i; - - out = new Complex128Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:assign:dtype=complex128', function benchmark( b ) { - var out; - var x1; - var x2; - var v; - var i; - - out = new Complex128Array( 10 ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=complex64', function benchmark( b ) { - var out; - var v; - var i; - - out = new Complex64Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:assign:dtype=complex64', function benchmark( b ) { - var out; - var x1; - var x2; - var v; - var i; - - out = new Complex64Array( 10 ); - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.complex128_complex.length.js b/benchmark/benchmark.complex128_complex.length.js deleted file mode 100644 index ee04b0c..0000000 --- a/benchmark/benchmark.complex128_complex.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.complex128_real.length.js b/benchmark/benchmark.complex128_real.length.js deleted file mode 100644 index 60e8113..0000000 --- a/benchmark/benchmark.complex128_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.complex64_complex.length.js b/benchmark/benchmark.complex64_complex.length.js deleted file mode 100644 index 400a142..0000000 --- a/benchmark/benchmark.complex64_complex.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.complex64_real.length.js b/benchmark/benchmark.complex64_real.length.js deleted file mode 100644 index 512c399..0000000 --- a/benchmark/benchmark.complex64_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.default_complex.length.js b/benchmark/benchmark.default_complex.length.js deleted file mode 100644 index 0f38b1b..0000000 --- a/benchmark/benchmark.default_complex.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::default,complex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.default_real.length.js b/benchmark/benchmark.default_real.length.js deleted file mode 100644 index 0e5ead1..0000000 --- a/benchmark/benchmark.default_real.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::default,real:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.float32_real.length.js b/benchmark/benchmark.float32_real.length.js deleted file mode 100644 index 4a5e48a..0000000 --- a/benchmark/benchmark.float32_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.float64_real.length.js b/benchmark/benchmark.float64_real.length.js deleted file mode 100644 index dfd2143..0000000 --- a/benchmark/benchmark.float64_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.generic_complex.length.js b/benchmark/benchmark.generic_complex.length.js deleted file mode 100644 index 3ebaaa7..0000000 --- a/benchmark/benchmark.generic_complex.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.generic_real.length.js b/benchmark/benchmark.generic_real.length.js deleted file mode 100644 index c796434..0000000 --- a/benchmark/benchmark.generic_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2347a15..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::default,real', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,complex', function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=float64', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=float32', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=generic', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=generic', function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=complex128', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=complex128', function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=complex64', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=complex64', function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 312171c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/linspace" -%% click B href "https://github.com/stdlib-js/array-linspace/tree/main" -%% click C href "https://github.com/stdlib-js/array-linspace/tree/production" -%% click D href "https://github.com/stdlib-js/array-linspace/tree/esm" -%% click E href "https://github.com/stdlib-js/array-linspace/tree/deno" -%% click F href "https://github.com/stdlib-js/array-linspace/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/linspace -[production-url]: https://github.com/stdlib-js/array-linspace/tree/production -[deno-url]: https://github.com/stdlib-js/array-linspace/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-linspace/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-linspace/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-linspace/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-linspace/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-linspace/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index be92f73..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import linspace from '../docs/types/index'; -export = linspace; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f753dcc..0000000 --- a/dist/index.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict";var g=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var O=g(function(rr,C){"use strict";function de(e,r,i,n){var f,u,l,a;if(i===0)return[];if(i===1)return n?[r]:[e];for(f=[e],n?u=i-1:u=i,l=(r-e)/u,a=1;a3&&(u=Le(n,arguments[3]),u))throw u;if(n.dtype==="generic")return v?Se(a,e,m,r,i,n.endpoint):Fe(e,r,i,n.endpoint);if(f=Ne(n.dtype),f===null)throw new TypeError(h('invalid option. `%s` option must be a real or complex floating-point data type or "generic". Option: `%s`.',"dtype",n.dtype));if(l=new f(i),n.dtype==="complex64")return K(Pe(l,0),a,e,m,r,i,n.endpoint),l;if(n.dtype==="complex128")return K(Ce(l,0),a,e,m,r,i,n.endpoint),l;if(v)throw new TypeError('invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or "generic".');return ke(l,e,r,i,n.endpoint)}Q.exports=Ie});var ae=g(function(fr,ie){"use strict";var Ae=require("@stdlib/complex-float32-ctor"),Ue=require("@stdlib/complex-float64-ctor"),Z=require("@stdlib/complex-float64-real"),$=require("@stdlib/complex-float64-imag"),ee=require("@stdlib/complex-float32-real"),re=require("@stdlib/complex-float32-imag");function Be(e,r,i,n,f,u,l){var a,m,v,t,c,o,p,s,d,b,q,y,x,w;if(u===0)return e;if(m=0,r==="float64"?(v=i,c=0):r==="complex64"?(m+=1,v=ee(i),c=re(i)):(v=Z(i),c=$(i)),n==="float64"?(t=f,o=0):n==="complex64"?(m+=1,t=ee(f),o=re(f)):(t=Z(f),o=$(f)),m===2?a=Ae:a=Ue,s=e.data,p=e.accessors[1],u===1)return l?p(s,0,new a(t,o)):p(s,0,new a(v,c)),e;for(p(s,0,new a(v,c)),l?x=u-1:x=u,q=(t-v)/x,y=(o-c)/x,w=1;w3&&(f=Ke(n,arguments[3]),f))throw f;if(m=Xe(i),m===null&&(m="generic"),m==="complex64")return ce(Ye(i,0),u,e,l,r,i.length,n.endpoint),i;if(m==="complex128")return ce(ze(i,0),u,e,l,r,i.length,n.endpoint),i;if(a){if(m==="generic")return v=te(i),Ge(v,u,e,l,r,i.length,n.endpoint),i;throw new TypeError('invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a "generic" array-like object.')}return v=te(i),v.accessorProtocol?(He(v,e,r,i.length,n.endpoint),i):(Je(i,e,r,i.length,n.endpoint),i)}oe.exports=We});var Ze=require("@stdlib/utils-define-nonenumerable-read-only-property"),se=W(),$e=pe();Ze(se,"assign",$e);module.exports=se; -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9c5d117..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/generic_real.js", "../lib/generic_complex.js", "../lib/typed_real.js", "../lib/typed_complex.js", "../lib/validate.js", "../lib/defaults.json", "../lib/main.js", "../lib/accessors_complex.js", "../lib/accessors_real.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @private\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, true );\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*\n* @example\n* var arr = linspace( 0, 100, 5, false );\n* // returns [ 0, 20, 40, 60, 80 ]\n*/\nfunction linspace( start, stop, len, endpoint ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ stop ];\n\t\t}\n\t\treturn [ start ];\n\t}\n\tarr = [ start ];\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( stop );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Complex64 = require( '@stdlib/complex-float32-ctor' );\nvar Complex128 = require( '@stdlib/complex-float64-ctor' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\nvar realf = require( '@stdlib/complex-float32-real' );\nvar imagf = require( '@stdlib/complex-float32-imag' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number array over a specified interval.\n*\n* @private\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*/\nfunction linspace( dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar arr;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ new cmplx( re2, im2 ) ];\n\t\t}\n\t\treturn [ new cmplx( re1, im1 ) ];\n\t}\n\tarr = [ new cmplx( re1, im1 ) ];\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tarr.push( new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( new cmplx( re2, im2 ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @private\n* @param {TypedArray} out - output array\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {TypedArray} linearly spaced array\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( out, 0, 100, out.length, true );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var out = new Float64Array( 5 );\n* var arr = linspace( out, 0, 100, out.length, false );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = stop;\n\t\t} else {\n\t\t\tout[ 0 ] = start;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = start;\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ i ] = start + (d*i);\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ N ] = stop;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\nvar realf = require( '@stdlib/complex-float32-real' );\nvar imagf = require( '@stdlib/complex-float32-imag' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns the results to a provided output array strided view.\n*\n* @private\n* @param {(Float32Array|Float64Array)} out - output array strided view\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {(Float32Array|Float64Array)} complex number array view\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = re2;\n\t\t\tout[ 1 ] = im2;\n\t\t} else {\n\t\t\tout[ 0 ] = re1;\n\t\t\tout[ 1 ] = im1;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = re1;\n\tout[ 1 ] = im1;\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced complex numbers:\n\tj = 2;\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ j ] = re1 + (dr*i);\n\t\tout[ j+1 ] = im1 + (di*i);\n\t\tj += 2;\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ j ] = re2;\n\t\tout[ j+1 ] = im2;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint] - boolean indicating whether the `stop` value in the output array\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'endpoint': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\topts.dtype = options.dtype;\n\t\tif ( !isString( opts.dtype ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dtype', opts.dtype ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'endpoint' ) ) {\n\t\topts.endpoint = options.endpoint;\n\t\tif ( !isBoolean( opts.endpoint ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'endpoint', opts.endpoint ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "{\n \"endpoint\": true\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar dtype = require( '@stdlib/complex-dtype' );\nvar ctors = require( '@stdlib/array-typed-float-ctors' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar DEFAULTS = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\nvar genreal = require( './generic_real.js' );\nvar gencmplx = require( './generic_complex.js' );\nvar typedreal = require( './typed_real.js' );\nvar typedcmplx = require( './typed_complex.js' );\nvar validate = require( './validate.js' );\nvar defaults = require( './defaults.json' );\n\n\n// VARIABLES //\n\nvar DEFAULT_COMPLEX_DTYPE = DEFAULTS.get( 'dtypes.complex_floating_point' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {Options} [options] - options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be a nonnegative integer\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @throws {TypeError} the output array data type must be a real or complex floating-point number data type or \"generic\"\n* @returns {(Array|TypedArray|ComplexArray)} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, {\n* 'dtype': 'generic'\n* });\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*/\nfunction linspace( start, stop, len ) {\n\tvar opts;\n\tvar ctor;\n\tvar err;\n\tvar out;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isNonNegativeInteger( len ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( dt1 === dt2 ) {\n\t\topts.dtype = dt1; // one of 'float64' || 'complex64' || 'complex128'\n\t} else {\n\t\t// If dtypes are different, then at least one is a complex number. According to type promotion rules, for all possible dtype permutations, the default output data type should be 'complex128'...\n\t\topts.dtype = DEFAULT_COMPLEX_DTYPE;\n\t}\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dtype === 'generic' ) {\n\t\tif ( flg ) {\n\t\t\treturn gencmplx( dt1, start, dt2, stop, len, opts.endpoint );\n\t\t}\n\t\treturn genreal( start, stop, len, opts.endpoint );\n\t}\n\tctor = ctors( opts.dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a real or complex floating-point data type or \"generic\". Option: `%s`.', 'dtype', opts.dtype ) );\n\t}\n\tout = new ctor( len );\n\tif ( opts.dtype === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( opts.dtype === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tthrow new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or \"generic\".' );\n\t}\n\treturn typedreal( out, start, stop, len, opts.endpoint );\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Complex64 = require( '@stdlib/complex-float32-ctor' );\nvar Complex128 = require( '@stdlib/complex-float64-ctor' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\nvar realf = require( '@stdlib/complex-float32-real' );\nvar imagf = require( '@stdlib/complex-float32-imag' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {string} dt1 - start value data type\n* @param {ComplexLike} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {ComplexLike} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar set;\n\tvar buf;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, new cmplx( re2, im2 ) );\n\t\t} else {\n\t\t\tset( buf, 0, new cmplx( re1, im1 ) );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, new cmplx( re1, im1 ) );\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate the linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tset( buf, i, new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, new cmplx( re2, im2 ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 6 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, true );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0, 200.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 5 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, false );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar buf;\n\tvar set;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, stop );\n\t\t} else {\n\t\t\tset( buf, 0, start );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, start );\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tset( buf, i, start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, stop );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar dtype = require( '@stdlib/complex-dtype' );\nvar adtype = require( '@stdlib/array-dtype' );\nvar reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar acccmplx = require( './accessors_complex.js' );\nvar accreal = require( './accessors_real.js' );\nvar typedcmplx = require( './typed_complex.js' );\nvar typedreal = require( './typed_real.js' );\nvar validate = require( './validate.js' );\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {Collection} out - output array\n* @param {Options} [options] - options\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be an array-like object\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @returns {Collection} output array\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( 0, 100, out );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*/\nfunction linspace( start, stop, out ) {\n\tvar opts;\n\tvar err;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\tvar odt;\n\tvar o;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\todt = adtype( out );\n\tif ( odt === null ) {\n\t\todt = 'generic';\n\t}\n\tif ( odt === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( odt === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tif ( odt === 'generic' ) {\n\t\t\to = arraylike2object( out );\n\t\t\tacccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint );\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a \"generic\" array-like object.' );\n\t}\n\to = arraylike2object( out );\n\tif ( o.accessorProtocol ) {\n\t\taccreal( o, start, stop, out.length, opts.endpoint );\n\t\treturn out;\n\t}\n\ttypedreal( out, start, stop, out.length, opts.endpoint );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = linspace;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Generate a linearly spaced array.\n*\n* @module @stdlib/array-linspace\n*\n* @example\n* var linspace = require( '@stdlib/array-linspace' );\n*\n* var arr = linspace( 0, 100, 6 );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* var linspace = require( '@stdlib/array-linspace' );\n*\n* var arr = linspace( 0, 100, 5, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var linspace = require( '@stdlib/array-linspace' );\n*\n* var arr = new Float64Array( 6 );\n* var out = linspace.assign( 0, 100, arr );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var linspace = require( '@stdlib/array-linspace' );\n*\n* var arr = new Float64Array( 5 );\n* var out = linspace.assign( 0, 100, arr, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwCA,SAASC,GAAUC,EAAOC,EAAMC,EAAKC,EAAW,CAC/C,IAAIC,EACAC,EACAC,EACAC,EAEJ,GAAKL,IAAQ,EACZ,MAAO,CAAC,EAGT,GAAKA,IAAQ,EACZ,OAAKC,EACG,CAAEF,CAAK,EAER,CAAED,CAAM,EAahB,IAXAI,EAAM,CAAEJ,CAAM,EAGTG,EACJE,EAAIH,EAAM,EAEVG,EAAIH,EAELI,GAAML,EAAKD,GAAUK,EAGfE,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAMJ,EAASM,EAAEC,CAAG,EAGzB,OAAKJ,GACJC,EAAI,KAAMH,CAAK,EAETG,CACR,CAKAN,EAAO,QAAUC,KChFjB,IAAAS,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAY,QAAS,8BAA+B,EACpDC,GAAa,QAAS,8BAA+B,EACrDC,EAAO,QAAS,8BAA+B,EAC/CC,EAAO,QAAS,8BAA+B,EAC/CC,EAAQ,QAAS,8BAA+B,EAChDC,EAAQ,QAAS,8BAA+B,EAiBpD,SAASC,GAAUC,EAAKC,EAAOC,EAAKC,EAAMC,EAAKC,EAAW,CACzD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKd,IAAQ,EACZ,MAAO,CAAC,EAgCT,GA9BAG,EAAQ,EACHP,IAAQ,WACZS,EAAMR,EACNU,EAAM,GACKX,IAAQ,aACnBO,GAAS,EACTE,EAAMZ,EAAOI,CAAM,EACnBU,EAAMb,EAAOG,CAAM,IAEnBQ,EAAMd,EAAMM,CAAM,EAClBU,EAAMf,EAAMK,CAAM,GAEdC,IAAQ,WACZQ,EAAMP,EACNS,EAAM,GACKV,IAAQ,aACnBK,GAAS,EACTG,EAAMb,EAAOM,CAAK,EAClBS,EAAMd,EAAOK,CAAK,IAElBO,EAAMf,EAAMQ,CAAK,EACjBS,EAAMhB,EAAMO,CAAK,GAGbI,IAAU,EACdD,EAAQb,GAERa,EAAQZ,GAGJU,IAAQ,EACZ,OAAKC,EACG,CAAE,IAAIC,EAAOI,EAAKE,CAAI,CAAE,EAEzB,CAAE,IAAIN,EAAOG,EAAKE,CAAI,CAAE,EAchC,IAZAH,EAAM,CAAE,IAAIF,EAAOG,EAAKE,CAAI,CAAE,EAGzBN,EACJY,EAAIb,EAAM,EAEVa,EAAIb,EAELW,GAAOL,EAAID,GAAQQ,EACnBD,GAAOJ,EAAID,GAAQM,EAGbC,EAAI,EAAGA,EAAID,EAAGC,IACnBL,EAAKJ,EAAOM,EAAGG,EACfJ,EAAKH,EAAOK,EAAGE,EACfV,EAAI,KAAM,IAAIF,EAAOO,EAAIC,CAAG,CAAE,EAG/B,OAAKT,GACJG,EAAI,KAAM,IAAIF,EAAOI,EAAKE,CAAI,CAAE,EAE1BJ,CACR,CAKAhB,EAAO,QAAUO,KC7HjB,IAAAoB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA+CA,SAASC,GAAUC,EAAKC,EAAOC,EAAMC,EAAKC,EAAW,CACpD,IAAIC,EACAC,EACAC,EAEJ,GAAKJ,IAAQ,EACZ,OAAOH,EAGR,GAAKG,IAAQ,EACZ,OAAKC,EACJJ,EAAK,CAAE,EAAIE,EAEXF,EAAK,CAAE,EAAIC,EAELD,EAaR,IAXAA,EAAK,CAAE,EAAIC,EAGNG,EACJC,EAAIF,EAAM,EAEVE,EAAIF,EAELG,GAAMJ,EAAKD,GAAUI,EAGfE,EAAI,EAAGA,EAAIF,EAAGE,IACnBP,EAAKO,CAAE,EAAIN,EAASK,EAAEC,EAGvB,OAAKH,IACJJ,EAAKK,CAAE,EAAIH,GAELF,CACR,CAKAF,EAAO,QAAUC,KCxFjB,IAAAS,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,8BAA+B,EAC/CC,EAAO,QAAS,8BAA+B,EAC/CC,EAAQ,QAAS,8BAA+B,EAChDC,EAAQ,QAAS,8BAA+B,EAkBpD,SAASC,GAAUC,EAAKC,EAAKC,EAAOC,EAAKC,EAAMC,EAAKC,EAAW,CAC9D,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKV,IAAQ,EACZ,OAAOL,EAuBR,GArBKC,IAAQ,WACZM,EAAML,EACNO,EAAM,GACKR,IAAQ,aACnBM,EAAMV,EAAOK,CAAM,EACnBO,EAAMX,EAAOI,CAAM,IAEnBK,EAAMZ,EAAMO,CAAM,EAClBO,EAAMb,EAAMM,CAAM,GAEdC,IAAQ,WACZK,EAAMJ,EACNM,EAAM,GACKP,IAAQ,aACnBK,EAAMX,EAAOO,CAAK,EAClBM,EAAMZ,EAAOM,CAAK,IAElBI,EAAMb,EAAMS,CAAK,EACjBM,EAAMd,EAAMQ,CAAK,GAGbC,IAAQ,EACZ,OAAKC,GACJN,EAAK,CAAE,EAAIQ,EACXR,EAAK,CAAE,EAAIU,IAEXV,EAAK,CAAE,EAAIO,EACXP,EAAK,CAAE,EAAIS,GAELT,EAgBR,IAdAA,EAAK,CAAE,EAAIO,EACXP,EAAK,CAAE,EAAIS,EAGNH,EACJO,EAAIR,EAAM,EAEVQ,EAAIR,EAELM,GAAOH,EAAID,GAAQM,EACnBD,GAAOF,EAAID,GAAQI,EAGnBE,EAAI,EACED,EAAI,EAAGA,EAAID,EAAGC,IACnBd,EAAKe,CAAE,EAAIR,EAAOI,EAAGG,EACrBd,EAAKe,EAAE,CAAE,EAAIN,EAAOG,EAAGE,EACvBC,GAAK,EAGN,OAAKT,IACJN,EAAKe,CAAE,EAAIP,EACXR,EAAKe,EAAE,CAAE,EAAIL,GAEPV,CACR,CAKAN,EAAO,QAAUK,KCtHjB,IAAAiB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,GAAW,QAAS,0BAA2B,EAAE,YACjDC,GAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAS,QAAS,uBAAwB,EAyB9C,SAASC,GAAUC,EAAMC,EAAU,CAClC,OAAMP,GAAUO,CAAQ,EAGnBN,EAAYM,EAAS,OAAQ,IACjCD,EAAK,MAAQC,EAAQ,MAChB,CAACL,GAAUI,EAAK,KAAM,GACnB,IAAI,UAAWF,EAAQ,8DAA+D,QAASE,EAAK,KAAM,CAAE,EAGhHL,EAAYM,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACJ,GAAWG,EAAK,QAAS,GACvB,IAAI,UAAWF,EAAQ,+DAAgE,WAAYE,EAAK,QAAS,CAAE,EAGrH,KAdC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAehH,CAKAR,EAAO,QAAUM,KCzEjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,GAAA,CAAAA,GAAA,SACI,SAAY,EAChB,ICFA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,GAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAQ,QAAS,iCAAkC,EACnDC,EAAQ,QAAS,uBAAwB,EACzCC,GAAQ,QAAS,iCAAkC,EACnDC,GAAgB,QAAS,4CAA6C,EACtEC,GAAiB,QAAS,6CAA8C,EACxEC,GAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAU,IACVC,GAAW,IACXC,GAAY,IACZC,EAAa,IACbC,GAAW,IACXC,GAAW,IAKXC,GAAwBR,GAAS,IAAK,+BAAgC,EA6B1E,SAASS,GAAUC,EAAOC,EAAMC,EAAM,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,OAAOT,GAAU,SAAW,CAEhC,GADAO,EAAMrB,EAAOc,CAAM,EACdO,IAAQ,KAAO,CACnB,GAAK,CAACzB,EAAekB,CAAM,EAC1B,MAAM,IAAI,UAAWT,EAAQ,yFAA0FS,CAAM,CAAE,EAEhIO,EAAM,YACP,CACAE,EAAM,EACP,KAAO,IAAK,CAAC1B,EAAUiB,CAAM,GAAKf,EAAOe,CAAM,EAC9C,MAAM,IAAI,UAAWT,EAAQ,yFAA0FS,CAAM,CAAE,EAE/HO,EAAM,UAEP,GAAK,OAAON,GAAS,SAAW,CAE/B,GADAO,EAAMtB,EAAOe,CAAK,EACbO,IAAQ,KAAO,CACnB,GAAK,CAAC1B,EAAemB,CAAK,EACzB,MAAM,IAAI,UAAWV,EAAQ,0FAA2FU,CAAK,CAAE,EAEhIO,EAAM,YACP,CACAC,EAAM,EACP,KAAO,IAAK,CAAC1B,EAAUkB,CAAK,GAAKhB,EAAOgB,CAAK,EAC5C,MAAM,IAAI,UAAWV,EAAQ,0FAA2FU,CAAK,CAAE,EAE/HO,EAAM,UAEP,GAAK,CAACxB,GAAsBkB,CAAI,EAC/B,MAAM,IAAI,UAAWX,EAAQ,+EAAgFW,CAAI,CAAE,EAWpH,GATAC,EAAO,CACN,SAAYN,GAAS,QACtB,EACKU,IAAQC,EACZL,EAAK,MAAQI,EAGbJ,EAAK,MAAQL,GAET,UAAU,OAAS,IACvBO,EAAMT,GAAUO,EAAM,UAAW,CAAE,CAAE,EAChCE,GACJ,MAAMA,EAGR,GAAKF,EAAK,QAAU,UACnB,OAAKM,EACGhB,GAAUc,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKC,EAAK,QAAS,EAErDX,GAASQ,EAAOC,EAAMC,EAAKC,EAAK,QAAS,EAGjD,GADAC,EAAOjB,GAAOgB,EAAK,KAAM,EACpBC,IAAS,KACb,MAAM,IAAI,UAAWb,EAAQ,6GAA8G,QAASY,EAAK,KAAM,CAAE,EAGlK,GADAG,EAAM,IAAIF,EAAMF,CAAI,EACfC,EAAK,QAAU,YACnB,OAAAR,EAAYP,GAAekB,EAAK,CAAE,EAAGC,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKC,EAAK,QAAS,EACxEG,EAER,GAAKH,EAAK,QAAU,aACnB,OAAAR,EAAYN,GAAgBiB,EAAK,CAAE,EAAGC,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKC,EAAK,QAAS,EACzEG,EAER,GAAKG,EACJ,MAAM,IAAI,UAAW,0JAA2J,EAEjL,OAAOf,GAAWY,EAAKN,EAAOC,EAAMC,EAAKC,EAAK,QAAS,CACxD,CAKAtB,EAAO,QAAUkB,KC1JjB,IAAAW,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAY,QAAS,8BAA+B,EACpDC,GAAa,QAAS,8BAA+B,EACrDC,EAAO,QAAS,8BAA+B,EAC/CC,EAAO,QAAS,8BAA+B,EAC/CC,GAAQ,QAAS,8BAA+B,EAChDC,GAAQ,QAAS,8BAA+B,EAoBpD,SAASC,GAAUC,EAAKC,EAAKC,EAAOC,EAAKC,EAAMC,EAAKC,EAAW,CAC9D,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKf,IAAQ,EACZ,OAAOL,EAoCR,GAlCAQ,EAAQ,EACHP,IAAQ,WACZQ,EAAMP,EACNS,EAAM,GACKV,IAAQ,aACnBO,GAAS,EACTC,EAAMZ,GAAOK,CAAM,EACnBS,EAAMb,GAAOI,CAAM,IAEnBO,EAAMd,EAAMO,CAAM,EAClBS,EAAMf,EAAMM,CAAM,GAEdC,IAAQ,WACZO,EAAMN,EACNQ,EAAM,GACKT,IAAQ,aACnBK,GAAS,EACTE,EAAMb,GAAOO,CAAK,EAClBQ,EAAMd,GAAOM,CAAK,IAElBM,EAAMf,EAAMS,CAAK,EACjBQ,EAAMhB,EAAMQ,CAAK,GAGbI,IAAU,EACdD,EAAQd,GAERc,EAAQb,GAGToB,EAAMd,EAAI,KACVa,EAAMb,EAAI,UAAW,CAAE,EAGlBK,IAAQ,EACZ,OAAKC,EACJO,EAAKC,EAAK,EAAG,IAAIP,EAAOG,EAAKE,CAAI,CAAE,EAEnCC,EAAKC,EAAK,EAAG,IAAIP,EAAOE,EAAKE,CAAI,CAAE,EAE7BX,EAcR,IAZAa,EAAKC,EAAK,EAAG,IAAIP,EAAOE,EAAKE,CAAI,CAAE,EAG9BL,EACJa,EAAId,EAAM,EAEVc,EAAId,EAELY,GAAOP,EAAID,GAAQU,EACnBD,GAAON,EAAID,GAAQQ,EAGbC,EAAI,EAAGA,EAAID,EAAGC,IACnBL,EAAKN,EAAOQ,EAAGG,EACfJ,EAAKL,EAAOO,EAAGE,EACfP,EAAKC,EAAKM,EAAG,IAAIb,EAAOQ,EAAIC,CAAG,CAAE,EAGlC,OAAKV,GACJO,EAAKC,EAAKK,EAAG,IAAIZ,EAAOG,EAAKE,CAAI,CAAE,EAE7BZ,CACR,CAKAR,GAAO,QAAUO,KCvIjB,IAAAsB,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAqEA,SAASC,GAAUC,EAAKC,EAAOC,EAAMC,EAAKC,EAAW,CACpD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKN,IAAQ,EACZ,OAAOH,EAOR,GAJAK,EAAML,EAAI,KACVM,EAAMN,EAAI,UAAW,CAAE,EAGlBG,IAAQ,EACZ,OAAKC,EACJE,EAAKD,EAAK,EAAGH,CAAK,EAElBI,EAAKD,EAAK,EAAGJ,CAAM,EAEbD,EAaR,IAXAM,EAAKD,EAAK,EAAGJ,CAAM,EAGdG,EACJG,EAAIJ,EAAM,EAEVI,EAAIJ,EAELK,GAAMN,EAAKD,GAAUM,EAGfE,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAKD,EAAKI,EAAGR,EAASO,EAAEC,CAAG,EAG5B,OAAKL,GACJE,EAAKD,EAAKE,EAAGL,CAAK,EAEZF,CACR,CAKAF,GAAO,QAAUC,KCpHjB,IAAAW,GAAAC,EAAA,SAAAC,GAAAC,GAAA,cAsBA,IAAIC,GAAgB,QAAS,gCAAiC,EAC1DC,GAAW,QAAS,0BAA2B,EAAE,YACjDC,GAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAC1CC,GAAQ,QAAS,iCAAkC,EACnDC,GAAQ,QAAS,uBAAwB,EACzCC,GAAS,QAAS,qBAAsB,EACxCC,GAAgB,QAAS,4CAA6C,EACtEC,GAAiB,QAAS,6CAA8C,EACxEC,GAAmB,QAAS,qCAAsC,EAClEC,GAAW,KACXC,GAAU,KACVC,GAAa,IACbC,GAAY,IACZC,GAAW,IACXC,GAAW,IA4Bf,SAASC,GAAUC,EAAOC,EAAMC,EAAM,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,OAAOT,GAAU,SAAW,CAEhC,GADAK,EAAMjB,GAAOY,CAAM,EACdK,IAAQ,KAAO,CACnB,GAAK,CAACtB,GAAeiB,CAAM,EAC1B,MAAM,IAAI,UAAWd,EAAQ,yFAA0Fc,CAAM,CAAE,EAEhIK,EAAM,YACP,CACAE,EAAM,EACP,KAAO,IAAK,CAACvB,GAAUgB,CAAM,GAAKb,GAAOa,CAAM,EAC9C,MAAM,IAAI,UAAWd,EAAQ,yFAA0Fc,CAAM,CAAE,EAE/HK,EAAM,UAEP,GAAK,OAAOJ,GAAS,SAAW,CAE/B,GADAK,EAAMlB,GAAOa,CAAK,EACbK,IAAQ,KAAO,CACnB,GAAK,CAACvB,GAAekB,CAAK,EACzB,MAAM,IAAI,UAAWf,EAAQ,0FAA2Fe,CAAK,CAAE,EAEhIK,EAAM,YACP,CACAC,EAAM,EACP,KAAO,IAAK,CAACvB,GAAUiB,CAAK,GAAKd,GAAOc,CAAK,EAC5C,MAAM,IAAI,UAAWf,EAAQ,0FAA2Fe,CAAK,CAAE,EAE/HK,EAAM,UAEP,GAAK,CAACrB,GAAciB,CAAI,EACvB,MAAM,IAAI,UAAWhB,EAAQ,8EAA+EgB,CAAI,CAAE,EAKnH,GAHAC,EAAO,CACN,SAAYL,GAAS,QACtB,EACK,UAAU,OAAS,IACvBM,EAAMP,GAAUM,EAAM,UAAW,CAAE,CAAE,EAChCC,GACJ,MAAMA,EAOR,GAJAI,EAAMnB,GAAQa,CAAI,EACbM,IAAQ,OACZA,EAAM,WAEFA,IAAQ,YACZ,OAAAb,GAAYL,GAAeY,EAAK,CAAE,EAAGG,EAAKL,EAAOM,EAAKL,EAAMC,EAAI,OAAQC,EAAK,QAAS,EAC/ED,EAER,GAAKM,IAAQ,aACZ,OAAAb,GAAYJ,GAAgBW,EAAK,CAAE,EAAGG,EAAKL,EAAOM,EAAKL,EAAMC,EAAI,OAAQC,EAAK,QAAS,EAChFD,EAER,GAAKK,EAAM,CACV,GAAKC,IAAQ,UACZ,OAAAC,EAAIjB,GAAkBU,CAAI,EAC1BT,GAAUgB,EAAGJ,EAAKL,EAAOM,EAAKL,EAAMC,EAAI,OAAQC,EAAK,QAAS,EACvDD,EAER,MAAM,IAAI,UAAW,gKAAiK,CACvL,CAEA,OADAO,EAAIjB,GAAkBU,CAAI,EACrBO,EAAE,kBACNf,GAASe,EAAGT,EAAOC,EAAMC,EAAI,OAAQC,EAAK,QAAS,EAC5CD,IAERN,GAAWM,EAAKF,EAAOC,EAAMC,EAAI,OAAQC,EAAK,QAAS,EAChDD,EACR,CAKApB,GAAO,QAAUiB,KChFjB,IAAIW,GAAc,QAAS,uDAAwD,EAC/EC,GAAO,IACPC,GAAS,KAKbF,GAAaC,GAAM,SAAUC,EAAO,EAKpC,OAAO,QAAUD", - "names": ["require_generic_real", "__commonJSMin", "exports", "module", "linspace", "start", "stop", "len", "endpoint", "arr", "N", "d", "i", "require_generic_complex", "__commonJSMin", "exports", "module", "Complex64", "Complex128", "real", "imag", "realf", "imagf", "linspace", "dt1", "start", "dt2", "stop", "len", "endpoint", "cmplx", "isf32", "arr", "re1", "re2", "im1", "im2", "re", "im", "dr", "di", "N", "i", "require_typed_real", "__commonJSMin", "exports", "module", "linspace", "out", "start", "stop", "len", "endpoint", "N", "d", "i", "require_typed_complex", "__commonJSMin", "exports", "module", "real", "imag", "realf", "imagf", "linspace", "out", "dt1", "start", "dt2", "stop", "len", "endpoint", "re1", "re2", "im1", "im2", "dr", "di", "N", "i", "j", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isString", "isBoolean", "format", "validate", "opts", "options", "require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "isComplexLike", "isNumber", "isNonNegativeInteger", "isnan", "dtype", "ctors", "reinterpret64", "reinterpret128", "DEFAULTS", "format", "genreal", "gencmplx", "typedreal", "typedcmplx", "validate", "defaults", "DEFAULT_COMPLEX_DTYPE", "linspace", "start", "stop", "len", "opts", "ctor", "err", "out", "dt1", "dt2", "flg", "require_accessors_complex", "__commonJSMin", "exports", "module", "Complex64", "Complex128", "real", "imag", "realf", "imagf", "linspace", "out", "dt1", "start", "dt2", "stop", "len", "endpoint", "cmplx", "isf32", "re1", "re2", "im1", "im2", "set", "buf", "re", "im", "dr", "di", "N", "i", "require_accessors_real", "__commonJSMin", "exports", "module", "linspace", "out", "start", "stop", "len", "endpoint", "buf", "set", "N", "d", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexLike", "isNumber", "isCollection", "format", "isnan", "dtype", "adtype", "reinterpret64", "reinterpret128", "arraylike2object", "acccmplx", "accreal", "typedcmplx", "typedreal", "validate", "defaults", "linspace", "start", "stop", "out", "opts", "err", "dt1", "dt2", "flg", "odt", "o", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 1428197..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,130 +0,0 @@ - -{{alias}}( start, stop, length[, options] ) - Generates a linearly spaced array over a specified interval. - - If the specified length is zero, the function returns an empty array. - - If the specified length is one, the function returns an array containing - `stop`, but not `start`, when `endpoint` is true; otherwise, the function - returns an array containing `start`, but not `stop`. - - For real-valued `start` and `stop`, if `start` is less than `stop`, the - output array will contain ascending values, and, if `start` is greater than - `stop`, the output array will contain descending values. - - When the output array length is greater than one and `endpoint` is true, the - output array is guaranteed to include the `start` and `stop` values. Beware, - however, that values between `start` and `stop` are subject to floating- - point rounding errors. - - If both `start` and `stop` are real-valued, the output array data type may - be any floating-point data type or 'generic'. However, if either `start` or - `stop` are complex numbers, the output array type must be a complex - floating-point data type or 'generic'. - - When writing to a complex floating-point output array, real-valued `start` - and `stop` values are treated as complex numbers having a real component - equaling the provided value and having an imaginary component equaling zero. - - When generating linearly spaced complex floating-point numbers, the real and - imaginary components are generated separately. - - Parameters - ---------- - start: number|ComplexLike - Start of interval. - - stop: number|ComplexLike - End of interval. - - length: integer - Length of output array. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Output array data type. Must be a floating-point data type or 'generic'. - If both `start` and `stop` are the same type (either 'float64', - 'complex64', or 'complex128'), the default output array data type is - the same type as the input values (either 'float64', 'complex64', or - 'complex128', respectively). Otherwise, the default output array data - type is 'complex128'. - - options.endpoint: boolean (optional) - Boolean indicating whether to include the `stop` value in the output - array. If false, the function generates `length + 1` linearly spaced - values over the interval `[start, stop]` and only writes `length` values - to the output array, thus excluding `stop` from the output array. - Accordingly, for a fixed `length`, the spacing between adjacent values - in the output array changes depending on the value of `endpoint`. - Default: true. - - Returns - ------- - arr: Array - Linearly spaced array. - - Examples - -------- - > var arr = {{alias}}( 0.0, 100.0, 6 ) - [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - > arr = {{alias}}( 0.0, 100.0, 5, { 'endpoint': false } ) - [ 0.0, 20.0, 40.0, 60.0, 80.0 ] - > arr = {{alias}}( 0.0, 100.0, 6, { 'dtype': 'generic' } ) - [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - - -{{alias}}.assign( start, stop, out[, options] ) - Generates a linearly spaced sequence over a specified interval and assigns - the results to a provided output array. - - If the provided output array is empty, the function returns the provided - output array unchanged. - - If the provided output array contains a single element, the function writes - the `stop` value, but not `start`, when `endpoint` is true; otherwise, the - function writes the `start` value, but not `stop`. - - Parameters - ---------- - start: number|ComplexLike - Start of interval. - - stop: number|ComplexLike - End of interval. - - out: ArrayLikeObject - Output array. - - options: Object (optional) - Options. - - options.endpoint: boolean (optional) - Boolean indicating whether to include the `stop` value in the output - array. If false, the function generates `N+1` linearly spaced values - (where `N` is the length of the provided output array) over the interval - `[start, stop]` and only writes `N` values to the output array, thus - excluding `stop` from the output array. Accordingly, for a fixed `N`, - the spacing between adjacent values in the output array changes - depending on the value of `endpoint`. Default: true. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var arr = [ 0, 0, 0, 0, 0, 0 ]; - > var out = {{alias}}.assign( 0, 100, arr ) - [ 0, 20, 40, 60, 80, 100 ] - > var bool = ( arr === out ) - true - > arr = [ 0, 0, 0, 0, 0 ]; - > out = {{alias}}.assign( 0, 100, arr, { 'endpoint': false } ) - [ 0, 20, 40, 60, 80 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 517e2a8..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,390 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex64 = require( '@stdlib/complex-float32-ctor' ); -import Complex128 = require( '@stdlib/complex-float64-ctor' ); -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import linspace = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - linspace( 0, 11, 20 ); // $ExpectType Float64Array - - linspace( 0, 11, 20, { 'endpoint': true } ); // $ExpectType Float64Array - linspace( 0, 11, 20, { 'endpoint': false } ); // $ExpectType Float64Array - - linspace( 0, 11, 20, { 'dtype': 'float64' } ); // $ExpectType Float64Array - linspace( 0, 11, 20, { 'dtype': 'float32' } ); // $ExpectType Float32Array - linspace( 0, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( 0, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( 0, 11, 20, { 'dtype': 'generic' } ); // $ExpectType number[] - - const z1 = new Complex64( 0.0, 0.0 ); - const z2 = new Complex64( 100.0, 10.0 ); - const z3 = new Complex128( 0.0, 0.0 ); - const z4 = new Complex128( 100.0, 10.0 ); - - linspace( z1, 11, 20 ); // $ExpectType Complex128Array - linspace( 0, z2, 20 ); // $ExpectType Complex128Array - linspace( z1, z2, 20 ); // $ExpectType Complex64Array - - linspace( z1, z4, 20 ); // $ExpectType Complex128Array - linspace( z3, z2, 20 ); // $ExpectType Complex128Array - - linspace( 0, z4, 20 ); // $ExpectType Complex128Array - linspace( z3, 11, 20 ); // $ExpectType Complex128Array - linspace( z3, z4, 20 ); // $ExpectType Complex128Array - - linspace( z1, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z1, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z1, 11, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( 0, z2, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( 0, z2, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( 0, z2, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z1, z2, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z1, z2, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z1, z2, 20, { 'dtype': 'generic' } ); // $ExpectType Complex64[] - - linspace( z1, z4, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z1, z4, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z1, z4, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z3, z2, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z3, z2, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z3, z2, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z3, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z3, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z3, 11, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( 0, z4, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( 0, z4, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( 0, z4, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z3, z4, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z3, z4, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z3, z4, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] -} - -// The compiler throws an error if the function is not provided a number or complex number for the first argument... -{ - const z = new Complex64( 1.0, 2.0 ); - - linspace( true, 10, 100 ); // $ExpectError - linspace( false, 10, 100 ); // $ExpectError - linspace( '5', 10, 100 ); // $ExpectError - linspace( [], 10, 100 ); // $ExpectError - linspace( {}, 10, 100 ); // $ExpectError - linspace( ( x: number ): number => x, 10, 100 ); // $ExpectError - - linspace( true, 10, 100, {} ); // $ExpectError - linspace( false, 10, 100, {} ); // $ExpectError - linspace( '5', 10, 100, {} ); // $ExpectError - linspace( [], 10, 100, {} ); // $ExpectError - linspace( {}, 10, 100, {} ); // $ExpectError - linspace( ( x: number ): number => x, 10, 100, {} ); // $ExpectError - - linspace( true, z, 100 ); // $ExpectError - linspace( false, z, 100 ); // $ExpectError - linspace( '5', z, 100 ); // $ExpectError - linspace( [], z, 100 ); // $ExpectError - linspace( {}, z, 100 ); // $ExpectError - linspace( ( x: number ): number => x, z, 100 ); // $ExpectError - - linspace( true, z, 100, {} ); // $ExpectError - linspace( false, z, 100, {} ); // $ExpectError - linspace( '5', z, 100, {} ); // $ExpectError - linspace( [], z, 100, {} ); // $ExpectError - linspace( {}, z, 100, {} ); // $ExpectError - linspace( ( x: number ): number => x, z, 100, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a number or complex number for the second argument... -{ - const z = new Complex64( 1.0, 2.0 ); - - linspace( 0, true, 100 ); // $ExpectError - linspace( 0, false, 100 ); // $ExpectError - linspace( 0, '5', 100 ); // $ExpectError - linspace( 0, [], 100 ); // $ExpectError - linspace( 0, {}, 100 ); // $ExpectError - linspace( 0, ( x: number ): number => x, 100 ); // $ExpectError - - linspace( 0, true, 100, {} ); // $ExpectError - linspace( 0, false, 100, {} ); // $ExpectError - linspace( 0, '5', 100, {} ); // $ExpectError - linspace( 0, [], 100, {} ); // $ExpectError - linspace( 0, {}, 100, {} ); // $ExpectError - linspace( 0, ( x: number ): number => x, 100, {} ); // $ExpectError - - linspace( z, true, 100 ); // $ExpectError - linspace( z, false, 100 ); // $ExpectError - linspace( z, '5', 100 ); // $ExpectError - linspace( z, [], 100 ); // $ExpectError - linspace( z, {}, 100 ); // $ExpectError - linspace( z, ( x: number ): number => x, 100 ); // $ExpectError - - linspace( z, true, 100, {} ); // $ExpectError - linspace( z, false, 100, {} ); // $ExpectError - linspace( z, '5', 100, {} ); // $ExpectError - linspace( z, [], 100, {} ); // $ExpectError - linspace( z, {}, 100, {} ); // $ExpectError - linspace( z, ( x: number ): number => x, 100, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a number for the third argument... -{ - linspace( 2, 20, '5' ); // $ExpectError - linspace( 3, 20, true ); // $ExpectError - linspace( 4, 20, false ); // $ExpectError - linspace( 2, 20, null ); // $ExpectError - linspace( 2, 20, [] ); // $ExpectError - linspace( 2, 20, {} ); // $ExpectError - linspace( 9, 20, ( x: number ): number => x ); // $ExpectError - - linspace( 2, 20, '5', {} ); // $ExpectError - linspace( 3, 20, true, {} ); // $ExpectError - linspace( 4, 20, false, {} ); // $ExpectError - linspace( 2, 20, null, {} ); // $ExpectError - linspace( 2, 20, [], {} ); // $ExpectError - linspace( 2, 20, {}, {} ); // $ExpectError - linspace( 9, 20, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided an object for the fourth argument... -{ - linspace( 2, 20, 100, '5' ); // $ExpectError - linspace( 3, 20, 100, true ); // $ExpectError - linspace( 4, 20, 100, false ); // $ExpectError - linspace( 2, 20, 100, [] ); // $ExpectError - linspace( 9, 20, 100, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid `dtype` option... -{ - linspace( 2, 20, 100, { 'dtype': '5' } ); // $ExpectError - linspace( 2, 20, 100, { 'dtype': 5 } ); // $ExpectError - linspace( 3, 20, 100, { 'dtype': true } ); // $ExpectError - linspace( 4, 20, 100, { 'dtype': false } ); // $ExpectError - linspace( 2, 20, 100, { 'dtype': [] } ); // $ExpectError - linspace( 2, 20, 100, { 'dtype': {} } ); // $ExpectError - linspace( 9, 20, 100, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid `endpoint` option... -{ - linspace( 2, 20, 100, { 'endpoint': '5' } ); // $ExpectError - linspace( 2, 20, 100, { 'endpoint': 5 } ); // $ExpectError - linspace( 2, 20, 100, { 'endpoint': [] } ); // $ExpectError - linspace( 2, 20, 100, { 'endpoint': {} } ); // $ExpectError - linspace( 9, 20, 100, { 'endpoint': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - linspace(); // $ExpectError - linspace( 3 ); // $ExpectError - linspace( 3, 10 ); // $ExpectError - linspace( 3, 10, 100, {}, null ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an output array... -{ - const o1 = new Float64Array( 10 ); - const o2 = new Float32Array( 10 ); - const o3 = [ 1, 2, 3, 4 ]; - const o4 = new Complex128Array( 10 ); - const o5 = new Complex64Array( 10 ); - - linspace.assign( 0, 11, o1 ); // $ExpectType Float64Array - - linspace.assign( 0, 11, o1, { 'endpoint': true } ); // $ExpectType Float64Array - linspace.assign( 0, 11, o1, { 'endpoint': false } ); // $ExpectType Float64Array - - linspace.assign( 0, 11, o2 ); // $ExpectType Float32Array - linspace.assign( 0, 11, o3 ); // $ExpectType number[] - linspace.assign( 0, 11, o4 ); // $ExpectType Complex128Array - linspace.assign( 0, 11, o5 ); // $ExpectType Complex64Array - - const z1 = new Complex64( 0.0, 0.0 ); - const z2 = new Complex64( 100.0, 10.0 ); - const z3 = new Complex128( 0.0, 0.0 ); - const z4 = new Complex128( 100.0, 10.0 ); - - linspace.assign( z1, 11, o5 ); // $ExpectType Complex64Array - linspace.assign( 0, z2, o5 ); // $ExpectType Complex64Array - linspace.assign( z1, z2, o5 ); // $ExpectType Complex64Array - - linspace.assign( z1, z4, o5 ); // $ExpectType Complex64Array - linspace.assign( z3, z2, o5 ); // $ExpectType Complex64Array - - linspace.assign( 0, z4, o5 ); // $ExpectType Complex64Array - linspace.assign( z3, 11, o5 ); // $ExpectType Complex64Array - linspace.assign( z3, z4, o5 ); // $ExpectType Complex64Array - - linspace.assign( z1, 11, o4 ); // $ExpectType Complex128Array - linspace.assign( 0, z2, o4 ); // $ExpectType Complex128Array - linspace.assign( z1, z2, o4 ); // $ExpectType Complex128Array - - linspace.assign( z1, z4, o4 ); // $ExpectType Complex128Array - linspace.assign( z3, z2, o4 ); // $ExpectType Complex128Array - - linspace.assign( 0, z4, o4 ); // $ExpectType Complex128Array - linspace.assign( z3, 11, o4 ); // $ExpectType Complex128Array - linspace.assign( z3, z4, o4 ); // $ExpectType Complex128Array - - linspace.assign( z1, 11, o3 ); // $ExpectType Complex128[] - linspace.assign( 0, z2, o3 ); // $ExpectType Complex128[] - linspace.assign( z1, z2, o3 ); // $ExpectType Complex64[] - - linspace.assign( z1, z4, o3 ); // $ExpectType Complex128[] - linspace.assign( z3, z2, o3 ); // $ExpectType Complex128[] - - linspace.assign( 0, z4, o3 ); // $ExpectType Complex128[] - linspace.assign( z3, 11, o3 ); // $ExpectType Complex128[] - linspace.assign( z3, z4, o3 ); // $ExpectType Complex128[] -} - -// The compiler throws an error if the `assign` method is not provided a number or complex number for the first argument... -{ - const z = new Complex64( 1.0, 2.0 ); - const o1 = new Float64Array( 10 ); - const o2 = new Complex128Array( 10 ); - - linspace.assign( true, 10, o1 ); // $ExpectError - linspace.assign( false, 10, o1 ); // $ExpectError - linspace.assign( '5', 10, o1 ); // $ExpectError - linspace.assign( [], 10, o1 ); // $ExpectError - linspace.assign( {}, 10, o1 ); // $ExpectError - linspace.assign( ( x: number ): number => x, 10, o1 ); // $ExpectError - - linspace.assign( true, 10, o1, {} ); // $ExpectError - linspace.assign( false, 10, o1, {} ); // $ExpectError - linspace.assign( '5', 10, o1, {} ); // $ExpectError - linspace.assign( [], 10, o1, {} ); // $ExpectError - linspace.assign( {}, 10, o1, {} ); // $ExpectError - linspace.assign( ( x: number ): number => x, 10, o1, {} ); // $ExpectError - - linspace.assign( true, z, o2 ); // $ExpectError - linspace.assign( false, z, o2 ); // $ExpectError - linspace.assign( '5', z, o2 ); // $ExpectError - linspace.assign( [], z, o2 ); // $ExpectError - linspace.assign( {}, z, o2 ); // $ExpectError - linspace.assign( ( x: number ): number => x, z, o2 ); // $ExpectError - - linspace.assign( true, z, o2, {} ); // $ExpectError - linspace.assign( false, z, o2, {} ); // $ExpectError - linspace.assign( '5', z, o2, {} ); // $ExpectError - linspace.assign( [], z, o2, {} ); // $ExpectError - linspace.assign( {}, z, o2, {} ); // $ExpectError - linspace.assign( ( x: number ): number => x, z, o2, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided a number or complex number for the second argument... -{ - const z = new Complex64( 1.0, 2.0 ); - const o1 = new Float64Array( 10 ); - const o2 = new Complex128Array( 10 ); - - linspace.assign( 0, true, o1 ); // $ExpectError - linspace.assign( 0, false, o1 ); // $ExpectError - linspace.assign( 0, '5', o1 ); // $ExpectError - linspace.assign( 0, [], o1 ); // $ExpectError - linspace.assign( 0, {}, o1 ); // $ExpectError - linspace.assign( 0, ( x: number ): number => x, o1 ); // $ExpectError - - linspace.assign( 0, true, o1, {} ); // $ExpectError - linspace.assign( 0, false, o1, {} ); // $ExpectError - linspace.assign( 0, '5', o1, {} ); // $ExpectError - linspace.assign( 0, [], o1, {} ); // $ExpectError - linspace.assign( 0, {}, o1, {} ); // $ExpectError - linspace.assign( 0, ( x: number ): number => x, o1, {} ); // $ExpectError - - linspace.assign( z, true, o2 ); // $ExpectError - linspace.assign( z, false, o2 ); // $ExpectError - linspace.assign( z, '5', o2 ); // $ExpectError - linspace.assign( z, [], o2 ); // $ExpectError - linspace.assign( z, {}, o2 ); // $ExpectError - linspace.assign( z, ( x: number ): number => x, o2 ); // $ExpectError - - linspace.assign( z, true, o2, {} ); // $ExpectError - linspace.assign( z, false, o2, {} ); // $ExpectError - linspace.assign( z, '5', o2, {} ); // $ExpectError - linspace.assign( z, [], o2, {} ); // $ExpectError - linspace.assign( z, {}, o2, {} ); // $ExpectError - linspace.assign( z, ( x: number ): number => x, o2, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided an array-like object for the third argument... -{ - const z = new Complex64( 1.0, 2.0 ); - - linspace.assign( 0, 10, true ); // $ExpectError - linspace.assign( 0, 10, false ); // $ExpectError - linspace.assign( 0, 10, 5 ); // $ExpectError - linspace.assign( 0, 10, {} ); // $ExpectError - - linspace.assign( 0, 10, true, {} ); // $ExpectError - linspace.assign( 0, 10, false, {} ); // $ExpectError - linspace.assign( 0, 10, 5, {} ); // $ExpectError - linspace.assign( 0, 10, {}, {} ); // $ExpectError - - linspace.assign( z, z, true ); // $ExpectError - linspace.assign( z, z, false ); // $ExpectError - linspace.assign( z, z, 5 ); // $ExpectError - linspace.assign( z, z, {} ); // $ExpectError - - linspace.assign( z, z, true, {} ); // $ExpectError - linspace.assign( z, z, false, {} ); // $ExpectError - linspace.assign( z, z, 5, {} ); // $ExpectError - linspace.assign( z, z, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided an object for the fourth argument... -{ - linspace.assign( 2, 20, [], '5' ); // $ExpectError - linspace.assign( 3, 20, [], true ); // $ExpectError - linspace.assign( 4, 20, [], false ); // $ExpectError - linspace.assign( 2, 20, [], [] ); // $ExpectError - linspace.assign( 9, 20, [], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided a valid `endpoint` option... -{ - const out = new Float64Array( 10 ); - - linspace.assign( 2, 20, out, { 'endpoint': '5' } ); // $ExpectError - linspace.assign( 2, 20, out, { 'endpoint': 5 } ); // $ExpectError - linspace.assign( 2, 20, out, { 'endpoint': [] } ); // $ExpectError - linspace.assign( 2, 20, out, { 'endpoint': {} } ); // $ExpectError - linspace.assign( 9, 20, out, { 'endpoint': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - linspace.assign(); // $ExpectError - linspace.assign( 3 ); // $ExpectError - linspace.assign( 3, 10 ); // $ExpectError - linspace.assign( 3, 10, [], {}, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0b0c3df..0000000 --- a/examples/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var linspace = require( './../lib' ); - -// Define function options: -var opts = { - 'dtype': 'generic' -}; - -// Create arrays of varying lengths... -var out = linspace( 0, 10, 10, opts ); -console.log( out ); - -out = linspace( 0, 10, 11, opts ); -console.log( out ); - -out = linspace( 0, 10, 21, opts ); -console.log( out ); - -// Create an array with decremented values: -out = linspace( 10, 0, 11, opts ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 069e66f..0daa789 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { FloatingPointDataType as DataType, ArrayLike, FloatOrComplexTypedArray, Complex64Array, Complex128Array } from '@stdlib/types/array'; import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3f3432a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-complex-like@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-dtype@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed-float-ctors@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex64@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex128@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-defaults@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float32-ctor@v0.0.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.0.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float32-real@v0.1.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float32-imag@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function T(e,t,r,n,s){var i,o,d;if(0===n)return e;if(1===n)return e[0]=s?r:t,e;for(e[0]=t,o=(r-t)/(i=s?n-1:n),d=1;d3&&(g=P(x,arguments[3])))throw g;if("generic"===x.dtype)return W?function(e,t,r,n,s,i){var o,d,p,l,m,u,x,y,g,w,b,E,T;if(0===s)return[];if(d=0,"float64"===e?(l=t,u=0):"complex64"===e?(d+=1,l=h(t),u=v(t)):(l=c(t),u=a(t)),"float64"===r?(m=n,x=0):"complex64"===r?(d+=1,m=h(n),x=v(n)):(m=c(n),x=a(n)),o=2===d?f:j,1===s)return i?[new o(m,x)]:[new o(l,u)];for(p=[new o(l,u)],w=(m-l)/(E=i?s-1:s),b=(x-u)/E,T=1;T3&&(u=P(l,arguments[3])))throw u;if(null===(V=b(o))&&(V="generic"),"complex64"===V)return k(d(o,0),x,e,y,n,o.length,l.endpoint),o;if("complex128"===V)return k(p(o,0),x,e,y,n,o.length,l.endpoint),o;if(g){if("generic"===V)return function(e,t,r,n,s,i,o){var d,p,l,m,u,x,y,g,w,b,E,T;if(0===i)return e;if(p=0,"float64"===t?(l=r,u=0):"complex64"===t?(p+=1,l=h(r),u=v(r)):(l=c(r),u=a(r)),"float64"===n?(m=s,x=0):"complex64"===n?(p+=1,m=h(s),x=v(s)):(m=c(s),x=a(s)),d=2===p?f:j,g=e.data,y=e.accessors[1],1===i)return y(g,0,o?new d(m,x):new d(l,u)),e;for(y(g,0,new d(l,u)),w=(m-l)/(E=o?i-1:i),b=(x-u)/E,T=1;T[ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var out = new Float64Array( 5 );\n* var arr = linspace( out, 0, 100, out.length, false );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = stop;\n\t\t} else {\n\t\t\tout[ 0 ] = start;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = start;\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ i ] = start + (d*i);\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ N ] = stop;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\nimport realf from '@stdlib/complex-float32-real';\nimport imagf from '@stdlib/complex-float32-imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns the results to a provided output array strided view.\n*\n* @private\n* @param {(Float32Array|Float64Array)} out - output array strided view\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {(Float32Array|Float64Array)} complex number array view\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = re2;\n\t\t\tout[ 1 ] = im2;\n\t\t} else {\n\t\t\tout[ 0 ] = re1;\n\t\t\tout[ 1 ] = im1;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = re1;\n\tout[ 1 ] = im1;\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced complex numbers:\n\tj = 2;\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ j ] = re1 + (dr*i);\n\t\tout[ j+1 ] = im1 + (di*i);\n\t\tj += 2;\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ j ] = re2;\n\t\tout[ j+1 ] = im2;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint] - boolean indicating whether the `stop` value in the output array\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'endpoint': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0132V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\topts.dtype = options.dtype;\n\t\tif ( !isString( opts.dtype ) ) {\n\t\t\treturn new TypeError( format( '0132W', 'dtype', opts.dtype ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'endpoint' ) ) {\n\t\topts.endpoint = options.endpoint;\n\t\tif ( !isBoolean( opts.endpoint ) ) {\n\t\t\treturn new TypeError( format( '0132o', 'endpoint', opts.endpoint ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport dtype from '@stdlib/complex-dtype';\nimport ctors from '@stdlib/array-typed-float-ctors';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport DEFAULTS from '@stdlib/array-defaults';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport genreal from './generic_real.js';\nimport gencmplx from './generic_complex.js';\nimport typedreal from './typed_real.js';\nimport typedcmplx from './typed_complex.js';\nimport validate from './validate.js';\nimport defaults from './defaults.json';\n\n\n// VARIABLES //\n\nvar DEFAULT_COMPLEX_DTYPE = DEFAULTS.get( 'dtypes.complex_floating_point' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {Options} [options] - options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be a nonnegative integer\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @throws {TypeError} the output array data type must be a real or complex floating-point number data type or \"generic\"\n* @returns {(Array|TypedArray|ComplexArray)} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, {\n* 'dtype': 'generic'\n* });\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*/\nfunction linspace( start, stop, len ) {\n\tvar opts;\n\tvar ctor;\n\tvar err;\n\tvar out;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( '0132j', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( '0132j', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( '0132k', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( '0132k', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isNonNegativeInteger( len ) ) {\n\t\tthrow new TypeError( format( '0132m', len ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( dt1 === dt2 ) {\n\t\topts.dtype = dt1; // one of 'float64' || 'complex64' || 'complex128'\n\t} else {\n\t\t// If dtypes are different, then at least one is a complex number. According to type promotion rules, for all possible dtype permutations, the default output data type should be 'complex128'...\n\t\topts.dtype = DEFAULT_COMPLEX_DTYPE;\n\t}\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dtype === 'generic' ) {\n\t\tif ( flg ) {\n\t\t\treturn gencmplx( dt1, start, dt2, stop, len, opts.endpoint );\n\t\t}\n\t\treturn genreal( start, stop, len, opts.endpoint );\n\t}\n\tctor = ctors( opts.dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( '0132n', 'dtype', opts.dtype ) );\n\t}\n\tout = new ctor( len );\n\tif ( opts.dtype === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( opts.dtype === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tthrow new TypeError( format('01308') );\n\t}\n\treturn typedreal( out, start, stop, len, opts.endpoint );\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from '@stdlib/complex-float32-ctor';\nimport Complex128 from '@stdlib/complex-float64-ctor';\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\nimport realf from '@stdlib/complex-float32-real';\nimport imagf from '@stdlib/complex-float32-imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number array over a specified interval.\n*\n* @private\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*/\nfunction linspace( dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar arr;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ new cmplx( re2, im2 ) ];\n\t\t}\n\t\treturn [ new cmplx( re1, im1 ) ];\n\t}\n\tarr = [ new cmplx( re1, im1 ) ];\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tarr.push( new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( new cmplx( re2, im2 ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @private\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, true );\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*\n* @example\n* var arr = linspace( 0, 100, 5, false );\n* // returns [ 0, 20, 40, 60, 80 ]\n*/\nfunction linspace( start, stop, len, endpoint ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ stop ];\n\t\t}\n\t\treturn [ start ];\n\t}\n\tarr = [ start ];\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( stop );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert-is-complex-like';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport dtype from '@stdlib/complex-dtype';\nimport adtype from '@stdlib/array-dtype';\nimport reinterpret64 from '@stdlib/strided-base-reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided-base-reinterpret-complex128';\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport acccmplx from './accessors_complex.js';\nimport accreal from './accessors_real.js';\nimport typedcmplx from './typed_complex.js';\nimport typedreal from './typed_real.js';\nimport validate from './validate.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {Collection} out - output array\n* @param {Options} [options] - options\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be an array-like object\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( 0, 100, out );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*/\nfunction linspace( start, stop, out ) {\n\tvar opts;\n\tvar err;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\tvar odt;\n\tvar o;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( '0132j', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( '0132j', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( '0132k', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( '0132k', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( '0132l', out ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\todt = adtype( out );\n\tif ( odt === null ) {\n\t\todt = 'generic';\n\t}\n\tif ( odt === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( odt === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tif ( odt === 'generic' ) {\n\t\t\to = arraylike2object( out );\n\t\t\tacccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint );\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format('01307') );\n\t}\n\to = arraylike2object( out );\n\tif ( o.accessorProtocol ) {\n\t\taccreal( o, start, stop, out.length, opts.endpoint );\n\t\treturn out;\n\t}\n\ttypedreal( out, start, stop, out.length, opts.endpoint );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from '@stdlib/complex-float32-ctor';\nimport Complex128 from '@stdlib/complex-float64-ctor';\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\nimport realf from '@stdlib/complex-float32-real';\nimport imagf from '@stdlib/complex-float32-imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {string} dt1 - start value data type\n* @param {ComplexLike} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {ComplexLike} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar set;\n\tvar buf;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, new cmplx( re2, im2 ) );\n\t\t} else {\n\t\t\tset( buf, 0, new cmplx( re1, im1 ) );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, new cmplx( re1, im1 ) );\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate the linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tset( buf, i, new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, new cmplx( re2, im2 ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 6 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, true );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0, 200.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 5 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, false );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar buf;\n\tvar set;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, stop );\n\t\t} else {\n\t\t\tset( buf, 0, start );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, start );\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tset( buf, i, start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, stop );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Generate a linearly spaced array.\n*\n* @module @stdlib/array-linspace\n*\n* @example\n* import linspace from '@stdlib/array-linspace';\n*\n* var arr = linspace( 0, 100, 6 );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* import linspace from '@stdlib/array-linspace';\n*\n* var arr = linspace( 0, 100, 5, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import linspace from '@stdlib/array-linspace';\n*\n* var arr = new Float64Array( 6 );\n* var out = linspace.assign( 0, 100, arr );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import linspace from '@stdlib/array-linspace';\n*\n* var arr = new Float64Array( 5 );\n* var out = linspace.assign( 0, 100, arr, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["linspace","out","start","stop","len","endpoint","N","d","i","dt1","dt2","re1","re2","im1","im2","dr","di","j","realf","imagf","real","imag","validate","opts","options","isObject","hasOwnProp","dtype","isString","TypeError","format","isBoolean","DEFAULT_COMPLEX_DTYPE","DEFAULTS","get","ctor","err","flg","isComplexLike","isNumber","isnan","isNonNegativeInteger","defaults","arguments","length","cmplx","isf32","arr","re","im","Complex64","Complex128","push","gencmplx","genreal","ctors","typedcmplx","reinterpret64","reinterpret128","typedreal","odt","o","isCollection","adtype","set","buf","data","accessors","acccmplx","arraylike2object","accessorProtocol","accreal","setReadOnly","main","assign"],"mappings":";;w1EA+CA,SAASA,EAAUC,EAAKC,EAAOC,EAAMC,EAAKC,GACzC,IAAIC,EACAC,EACAC,EAEJ,GAAa,IAARJ,EACJ,OAAOH,EAGR,GAAa,IAARG,EAMJ,OAJCH,EAAK,GADDI,EACOF,EAEAD,EAELD,EAaR,IAXAA,EAAK,GAAMC,EAQXK,GAAMJ,EAAKD,IAJVI,EADID,EACAD,EAAM,EAENA,GAKCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBP,EAAKO,GAAMN,EAASK,EAAEC,EAMvB,OAHKH,IACJJ,EAAKK,GAAMH,GAELF,CACR,CCxCA,SAASD,EAAUC,EAAKQ,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKC,GACnD,IAAIM,EACAC,EACAC,EACAC,EACAC,EACAC,EACAV,EACAE,EACAS,EAEJ,GAAa,IAARb,EACJ,OAAOH,EAuBR,GArBa,YAARQ,GACJE,EAAMT,EACNW,EAAM,GACa,cAARJ,GACXE,EAAMO,EAAOhB,GACbW,EAAMM,EAAOjB,KAEbS,EAAMS,EAAMlB,GACZW,EAAMQ,EAAMnB,IAEA,YAARQ,GACJE,EAAMT,EACNW,EAAM,GACa,cAARJ,GACXE,EAAMM,EAAOf,GACbW,EAAMK,EAAOhB,KAEbS,EAAMQ,EAAMjB,GACZW,EAAMO,EAAMlB,IAGA,IAARC,EAQJ,OAPKC,GACJJ,EAAK,GAAMW,EACXX,EAAK,GAAMa,IAEXb,EAAK,GAAMU,EACXV,EAAK,GAAMY,GAELZ,EAgBR,IAdAA,EAAK,GAAMU,EACXV,EAAK,GAAMY,EAQXE,GAAOH,EAAID,IAJVL,EADID,EACAD,EAAM,EAENA,GAGLY,GAAOF,EAAID,GAAQP,EAGnBW,EAAI,EACET,EAAI,EAAGA,EAAIF,EAAGE,IACnBP,EAAKgB,GAAMN,EAAOI,EAAGP,EACrBP,EAAKgB,EAAE,GAAMJ,EAAOG,EAAGR,EACvBS,GAAK,EAON,OAJKZ,IACJJ,EAAKgB,GAAML,EACXX,EAAKgB,EAAE,GAAMH,GAEPb,CACR,CC9DA,SAASqB,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,WACzBD,EAAKI,MAAQH,EAAQG,OACfC,EAAUL,EAAKI,QACb,IAAIE,UAAWC,EAAQ,QAAS,QAASP,EAAKI,QAGlDD,EAAYF,EAAS,cACzBD,EAAKlB,SAAWmB,EAAQnB,UAClB0B,EAAWR,EAAKlB,WACd,IAAIwB,UAAWC,EAAQ,QAAS,WAAYP,EAAKlB,WAGnD,KAdC,IAAIwB,UAAWC,EAAQ,QAASN,GAezC,UC1BIQ,EAAwBC,EAASC,IAAK,iCA6B1C,SAASlC,EAAUE,EAAOC,EAAMC,GAC/B,IAAImB,EACAY,EACAC,EACAnC,EACAQ,EACAC,EACA2B,EAEJ,GAAsB,iBAAVnC,EAAqB,CAEhC,GAAa,QADbO,EAAMkB,EAAOzB,IACO,CACnB,IAAMoC,EAAepC,GACpB,MAAM,IAAI2B,UAAWC,EAAQ,QAAS5B,IAEvCO,EAAM,YACN,CACD4B,GAAM,CACR,KAAQ,KAAME,EAAUrC,IAAWsC,EAAOtC,GACxC,MAAM,IAAI2B,UAAWC,EAAQ,QAAS5B,IAEtCO,EAAM,SACN,CACD,GAAqB,iBAATN,EAAoB,CAE/B,GAAa,QADbO,EAAMiB,EAAOxB,IACO,CACnB,IAAMmC,EAAenC,GACpB,MAAM,IAAI0B,UAAWC,EAAQ,QAAS3B,IAEvCO,EAAM,YACN,CACD2B,GAAM,CACR,KAAQ,KAAME,EAAUpC,IAAUqC,EAAOrC,GACvC,MAAM,IAAI0B,UAAWC,EAAQ,QAAS3B,IAEtCO,EAAM,SACN,CACD,IAAM+B,EAAsBrC,GAC3B,MAAM,IAAIyB,UAAWC,EAAQ,QAAS1B,IAWvC,IATAmB,EAAO,CACNlB,SAAYqC,IAGPf,MADDlB,IAAQC,EACCD,EAGAuB,EAETW,UAAUC,OAAS,IACvBR,EAAMd,EAAUC,EAAMoB,UAAW,KAEhC,MAAMP,EAGR,GAAoB,YAAfb,EAAKI,MACT,OAAKU,ECnFP,SAAmB5B,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKC,GAC9C,IAAIwC,EACAC,EACAC,EACApC,EACAC,EACAC,EACAC,EACAkC,EACAC,EACAlC,EACAC,EACAV,EACAE,EAEJ,GAAa,IAARJ,EACJ,MAAO,GAgCR,GA9BA0C,EAAQ,EACK,YAARrC,GACJE,EAAMT,EACNW,EAAM,GACa,cAARJ,GACXqC,GAAS,EACTnC,EAAMO,EAAOhB,GACbW,EAAMM,EAAOjB,KAEbS,EAAMS,EAAMlB,GACZW,EAAMQ,EAAMnB,IAEA,YAARQ,GACJE,EAAMT,EACNW,EAAM,GACa,cAARJ,GACXoC,GAAS,EACTlC,EAAMM,EAAOf,GACbW,EAAMK,EAAOhB,KAEbS,EAAMQ,EAAMjB,GACZW,EAAMO,EAAMlB,IAIZ0C,EADc,IAAVC,EACII,EAEAC,EAGI,IAAR/C,EACJ,OAAKC,EACG,CAAE,IAAIwC,EAAOjC,EAAKE,IAEnB,CAAE,IAAI+B,EAAOlC,EAAKE,IAc1B,IAZAkC,EAAM,CAAE,IAAIF,EAAOlC,EAAKE,IAQxBE,GAAOH,EAAID,IAJVL,EADID,EACAD,EAAM,EAENA,GAGLY,GAAOF,EAAID,GAAQP,EAGbE,EAAI,EAAGA,EAAIF,EAAGE,IACnBwC,EAAKrC,EAAOI,EAAGP,EACfyC,EAAKpC,EAAOG,EAAGR,EACfuC,EAAIK,KAAM,IAAIP,EAAOG,EAAIC,IAM1B,OAHK5C,GACJ0C,EAAIK,KAAM,IAAIP,EAAOjC,EAAKE,IAEpBiC,CACR,CDQUM,CAAU5C,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKmB,EAAKlB,UExFrD,SAAmBH,EAAOC,EAAMC,EAAKC,GACpC,IAAI0C,EACAzC,EACAC,EACAC,EAEJ,GAAa,IAARJ,EACJ,MAAO,GAGR,GAAa,IAARA,EACJ,OAAKC,EACG,CAAEF,GAEH,CAAED,GAaV,IAXA6C,EAAM,CAAE7C,GAQRK,GAAMJ,EAAKD,IAJVI,EADID,EACAD,EAAM,EAENA,GAKCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBuC,EAAIK,KAAMlD,EAASK,EAAEC,GAMtB,OAHKH,GACJ0C,EAAIK,KAAMjD,GAEJ4C,CACR,CFuDSO,CAASpD,EAAOC,EAAMC,EAAKmB,EAAKlB,UAGxC,GAAc,QADd8B,EAAOoB,EAAOhC,EAAKI,QAElB,MAAM,IAAIE,UAAWC,EAAQ,QAAS,QAASP,EAAKI,QAGrD,GADA1B,EAAM,IAAIkC,EAAM/B,GACI,cAAfmB,EAAKI,MAET,OADA6B,EAAYC,EAAexD,EAAK,GAAKQ,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKmB,EAAKlB,UAC/DJ,EAER,GAAoB,eAAfsB,EAAKI,MAET,OADA6B,EAAYE,EAAgBzD,EAAK,GAAKQ,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKmB,EAAKlB,UAChEJ,EAER,GAAKoC,EACJ,MAAM,IAAIR,UAAWC,EAAO,UAE7B,OAAO6B,EAAW1D,EAAKC,EAAOC,EAAMC,EAAKmB,EAAKlB,SAC/C,CGpFA,SAASL,EAAUE,EAAOC,EAAMF,GAC/B,IAAIsB,EACAa,EACA3B,EACAC,EACA2B,EACAuB,EACAC,EAEJ,GAAsB,iBAAV3D,EAAqB,CAEhC,GAAa,QADbO,EAAMkB,EAAOzB,IACO,CACnB,IAAMoC,EAAepC,GACpB,MAAM,IAAI2B,UAAWC,EAAQ,QAAS5B,IAEvCO,EAAM,YACN,CACD4B,GAAM,CACR,KAAQ,KAAME,EAAUrC,IAAWsC,EAAOtC,GACxC,MAAM,IAAI2B,UAAWC,EAAQ,QAAS5B,IAEtCO,EAAM,SACN,CACD,GAAqB,iBAATN,EAAoB,CAE/B,GAAa,QADbO,EAAMiB,EAAOxB,IACO,CACnB,IAAMmC,EAAenC,GACpB,MAAM,IAAI0B,UAAWC,EAAQ,QAAS3B,IAEvCO,EAAM,YACN,CACD2B,GAAM,CACR,KAAQ,KAAME,EAAUpC,IAAUqC,EAAOrC,GACvC,MAAM,IAAI0B,UAAWC,EAAQ,QAAS3B,IAEtCO,EAAM,SACN,CACD,IAAMoD,EAAc7D,GACnB,MAAM,IAAI4B,UAAWC,EAAQ,QAAS7B,IAKvC,GAHAsB,EAAO,CACNlB,SAAYqC,GAERC,UAAUC,OAAS,IACvBR,EAAMd,EAAUC,EAAMoB,UAAW,KAEhC,MAAMP,EAOR,GAHa,QADbwB,EAAMG,EAAQ9D,MAEb2D,EAAM,WAEM,cAARA,EAEJ,OADAJ,EAAYC,EAAexD,EAAK,GAAKQ,EAAKP,EAAOQ,EAAKP,EAAMF,EAAI2C,OAAQrB,EAAKlB,UACtEJ,EAER,GAAa,eAAR2D,EAEJ,OADAJ,EAAYE,EAAgBzD,EAAK,GAAKQ,EAAKP,EAAOQ,EAAKP,EAAMF,EAAI2C,OAAQrB,EAAKlB,UACvEJ,EAER,GAAKoC,EAAM,CACV,GAAa,YAARuB,EAGJ,OCnFH,SAAmB3D,EAAKQ,EAAKP,EAAOQ,EAAKP,EAAMC,EAAKC,GACnD,IAAIwC,EACAC,EACAnC,EACAC,EACAC,EACAC,EACAkD,EACAC,EAGAlD,EACAC,EACAV,EACAE,EAEJ,GAAa,IAARJ,EACJ,OAAOH,EAoCR,GAlCA6C,EAAQ,EACK,YAARrC,GACJE,EAAMT,EACNW,EAAM,GACa,cAARJ,GACXqC,GAAS,EACTnC,EAAMO,EAAOhB,GACbW,EAAMM,EAAOjB,KAEbS,EAAMS,EAAMlB,GACZW,EAAMQ,EAAMnB,IAEA,YAARQ,GACJE,EAAMT,EACNW,EAAM,GACa,cAARJ,GACXoC,GAAS,EACTlC,EAAMM,EAAOf,GACbW,EAAMK,EAAOhB,KAEbS,EAAMQ,EAAMjB,GACZW,EAAMO,EAAMlB,IAIZ0C,EADc,IAAVC,EACII,EAEAC,EAGTc,EAAMhE,EAAIiE,KACVF,EAAM/D,EAAIkE,UAAW,GAGR,IAAR/D,EAMJ,OAJC4D,EAAKC,EAAK,EADN5D,EACS,IAAIwC,EAAOjC,EAAKE,GAEhB,IAAI+B,EAAOlC,EAAKE,IAEvBZ,EAcR,IAZA+D,EAAKC,EAAK,EAAG,IAAIpB,EAAOlC,EAAKE,IAQ7BE,GAAOH,EAAID,IAJVL,EADID,EACAD,EAAM,EAENA,GAGLY,GAAOF,EAAID,GAAQP,EAGbE,EAAI,EAAGA,EAAIF,EAAGE,IAGnBwD,EAAKC,EAAKzD,EAAG,IAAIqC,EAFZlC,EAAOI,EAAGP,EACVK,EAAOG,EAAGR,IAIXH,GACJ2D,EAAKC,EAAK3D,EAAG,IAAIuC,EAAOjC,EAAKE,GAG/B,CDDGsD,CADAP,EAAIQ,EAAkBpE,GACTQ,EAAKP,EAAOQ,EAAKP,EAAMF,EAAI2C,OAAQrB,EAAKlB,UAC9CJ,EAER,MAAM,IAAI4B,UAAWC,EAAO,SAC5B,CAED,OADA+B,EAAIQ,EAAkBpE,IACfqE,kBElER,SAAmBrE,EAAKC,EAAOC,EAAMC,EAAKC,GACzC,IAAI4D,EACAD,EACA1D,EACAC,EACAC,EAEJ,GAAa,IAARJ,EACJ,OAAOH,EAOR,GAJAgE,EAAMhE,EAAIiE,KACVF,EAAM/D,EAAIkE,UAAW,GAGR,IAAR/D,EAMJ,OAJC4D,EAAKC,EAAK,EADN5D,EACSF,EAEAD,GAEPD,EAaR,IAXA+D,EAAKC,EAAK,EAAG/D,GAQbK,GAAMJ,EAAKD,IAJVI,EADID,EACAD,EAAM,EAENA,GAKCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBwD,EAAKC,EAAKzD,EAAGN,EAASK,EAAEC,GAGpBH,GACJ2D,EAAKC,EAAK3D,EAAGH,EAGf,CFyBEoE,CAASV,EAAG3D,EAAOC,EAAMF,EAAI2C,OAAQrB,EAAKlB,UACnCJ,IAER0D,EAAW1D,EAAKC,EAAOC,EAAMF,EAAI2C,OAAQrB,EAAKlB,UACvCJ,EACR,CGpEAuE,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/accessors_complex.js b/lib/accessors_complex.js deleted file mode 100644 index 6dfb8e5..0000000 --- a/lib/accessors_complex.js +++ /dev/null @@ -1,136 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); - - -// MAIN // - -/** -* Generates a linearly spaced complex number sequence over a specified interval and assigns results to a provided output array. -* -* @private -* @param {Object} out - output array object -* @param {ArrayLikeObject} out.data - output array data -* @param {Array} out.accessors - array element accessors -* @param {string} dt1 - start value data type -* @param {ComplexLike} start - start of interval -* @param {string} dt2 - stop value data type -* @param {ComplexLike} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Object} output array object -*/ -function linspace( out, dt1, start, dt2, stop, len, endpoint ) { - var cmplx; - var isf32; - var re1; - var re2; - var im1; - var im2; - var set; - var buf; - var re; - var im; - var dr; - var di; - var N; - var i; - - if ( len === 0 ) { - return out; - } - isf32 = 0; - if ( dt1 === 'float64' ) { - re1 = start; - im1 = 0.0; - } else if ( dt1 === 'complex64' ) { - isf32 += 1; - re1 = realf( start ); - im1 = imagf( start ); - } else { - re1 = real( start ); - im1 = imag( start ); - } - if ( dt2 === 'float64' ) { - re2 = stop; - im2 = 0.0; - } else if ( dt2 === 'complex64' ) { - isf32 += 1; - re2 = realf( stop ); - im2 = imagf( stop ); - } else { - re2 = real( stop ); - im2 = imag( stop ); - } - // Determine which complex number constructor to use according to type promotion rules: - if ( isf32 === 2 ) { - cmplx = Complex64; - } else { - cmplx = Complex128; - } - // Cache array object references: - buf = out.data; - set = out.accessors[ 1 ]; - - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - set( buf, 0, new cmplx( re2, im2 ) ); - } else { - set( buf, 0, new cmplx( re1, im1 ) ); - } - return out; - } - set( buf, 0, new cmplx( re1, im1 ) ); - - // Calculate the increments: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - dr = ( re2-re1 ) / N; - di = ( im2-im1 ) / N; - - // Generate the linearly spaced values: - for ( i = 1; i < N; i++ ) { - re = re1 + (dr*i); - im = im1 + (di*i); - set( buf, i, new cmplx( re, im ) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - set( buf, N, new cmplx( re2, im2 ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/accessors_real.js b/lib/accessors_real.js deleted file mode 100644 index d71c939..0000000 --- a/lib/accessors_real.js +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. -* -* @private -* @param {Object} out - output array object -* @param {ArrayLikeObject} out.data - output array data -* @param {Array} out.accessors - array element accessors -* @param {number} start - start of interval -* @param {number} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Object} output array object -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* function set( buf, i, v ) { -* buf[ i ] = v * 2.0; -* } -* -* var out = new Float64Array( 6 ); -* var obj = { -* 'data': out, -* 'accessors': [ null, set ] -* }; -* linspace( obj, 0, 100, out.length, true ); -* -* var arr = obj.data; -* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0, 200.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* function set( buf, i, v ) { -* buf[ i ] = v * 2.0; -* } -* -* var out = new Float64Array( 5 ); -* var obj = { -* 'data': out, -* 'accessors': [ null, set ] -* }; -* linspace( obj, 0, 100, out.length, false ); -* -* var arr = obj.data; -* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0 ] -*/ -function linspace( out, start, stop, len, endpoint ) { - var buf; - var set; - var N; - var d; - var i; - - if ( len === 0 ) { - return out; - } - // Cache array object references: - buf = out.data; - set = out.accessors[ 1 ]; - - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - set( buf, 0, stop ); - } else { - set( buf, 0, start ); - } - return out; - } - set( buf, 0, start ); - - // Calculate the increment: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - d = ( stop-start ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - set( buf, i, start + (d*i) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - set( buf, N, stop ); - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 0344921..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var dtype = require( '@stdlib/complex-dtype' ); -var adtype = require( '@stdlib/array-dtype' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var acccmplx = require( './accessors_complex.js' ); -var accreal = require( './accessors_real.js' ); -var typedcmplx = require( './typed_complex.js' ); -var typedreal = require( './typed_real.js' ); -var validate = require( './validate.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array. -* -* @param {(number|ComplexLike)} start - start of interval -* @param {(number|ComplexLike)} stop - end of interval -* @param {Collection} out - output array -* @param {Options} [options] - options -* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array -* @throws {TypeError} first argument must be either a real or complex number -* @throws {TypeError} second argument must be either a real or complex number -* @throws {TypeError} third argument must be an array-like object -* @throws {TypeError} last argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} the output array data type must be a complex number data type or "generic" when either `start` or `stop` is a complex number -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var out = new Float64Array( 6 ); -* var arr = linspace( 0, 100, out ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -*/ -function linspace( start, stop, out ) { - var opts; - var err; - var dt1; - var dt2; - var flg; - var odt; - var o; - - if ( typeof start === 'object' ) { - dt1 = dtype( start ); - if ( dt1 === null ) { - if ( !isComplexLike( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } - dt1 = 'complex128'; - } - flg = true; - } else if ( !isNumber( start ) || isnan( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } else { - dt1 = 'float64'; - } - if ( typeof stop === 'object' ) { - dt2 = dtype( stop ); - if ( dt2 === null ) { - if ( !isComplexLike( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } - dt2 = 'complex128'; - } - flg = true; - } else if ( !isNumber( stop ) || isnan( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } else { - dt2 = 'float64'; - } - if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', out ) ); - } - opts = { - 'endpoint': defaults.endpoint - }; - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - odt = adtype( out ); - if ( odt === null ) { - odt = 'generic'; - } - if ( odt === 'complex64' ) { - typedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( odt === 'complex128' ) { - typedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( flg ) { - if ( odt === 'generic' ) { - o = arraylike2object( out ); - acccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint ); - return out; - } - throw new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a "generic" array-like object.' ); - } - o = arraylike2object( out ); - if ( o.accessorProtocol ) { - accreal( o, start, stop, out.length, opts.endpoint ); - return out; - } - typedreal( out, start, stop, out.length, opts.endpoint ); - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 0afc16c..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "endpoint": true -} diff --git a/lib/generic_complex.js b/lib/generic_complex.js deleted file mode 100644 index 319d36b..0000000 --- a/lib/generic_complex.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); - - -// MAIN // - -/** -* Generates a linearly spaced complex number array over a specified interval. -* -* @private -* @param {string} dt1 - start value data type -* @param {(number|ComplexLike)} start - start of interval -* @param {string} dt2 - stop value data type -* @param {(number|ComplexLike)} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Array} linearly spaced array -*/ -function linspace( dt1, start, dt2, stop, len, endpoint ) { - var cmplx; - var isf32; - var arr; - var re1; - var re2; - var im1; - var im2; - var re; - var im; - var dr; - var di; - var N; - var i; - - if ( len === 0 ) { - return []; - } - isf32 = 0; - if ( dt1 === 'float64' ) { - re1 = start; - im1 = 0.0; - } else if ( dt1 === 'complex64' ) { - isf32 += 1; - re1 = realf( start ); - im1 = imagf( start ); - } else { - re1 = real( start ); - im1 = imag( start ); - } - if ( dt2 === 'float64' ) { - re2 = stop; - im2 = 0.0; - } else if ( dt2 === 'complex64' ) { - isf32 += 1; - re2 = realf( stop ); - im2 = imagf( stop ); - } else { - re2 = real( stop ); - im2 = imag( stop ); - } - // Determine which complex number constructor to use according to type promotion rules: - if ( isf32 === 2 ) { - cmplx = Complex64; - } else { - cmplx = Complex128; - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - return [ new cmplx( re2, im2 ) ]; - } - return [ new cmplx( re1, im1 ) ]; - } - arr = [ new cmplx( re1, im1 ) ]; - - // Calculate the increments: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - dr = ( re2-re1 ) / N; - di = ( im2-im1 ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - re = re1 + (dr*i); - im = im1 + (di*i); - arr.push( new cmplx( re, im ) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - arr.push( new cmplx( re2, im2 ) ); - } - return arr; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/generic_real.js b/lib/generic_real.js deleted file mode 100644 index dcebef3..0000000 --- a/lib/generic_real.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced array over a specified interval. -* -* @private -* @param {number} start - start of interval -* @param {number} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Array} linearly spaced array -* -* @example -* var arr = linspace( 0, 100, 6, true ); -* // returns [ 0, 20, 40, 60, 80, 100 ] -* -* @example -* var arr = linspace( 0, 100, 5, false ); -* // returns [ 0, 20, 40, 60, 80 ] -*/ -function linspace( start, stop, len, endpoint ) { - var arr; - var N; - var d; - var i; - - if ( len === 0 ) { - return []; - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - return [ stop ]; - } - return [ start ]; - } - arr = [ start ]; - - // Calculate the increment: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - d = ( stop-start ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - arr.push( start + (d*i) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - arr.push( stop ); - } - return arr; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 4b20729..0000000 --- a/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced array. -* -* @module @stdlib/array-linspace -* -* @example -* var linspace = require( '@stdlib/array-linspace' ); -* -* var arr = linspace( 0, 100, 6 ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* @example -* var linspace = require( '@stdlib/array-linspace' ); -* -* var arr = linspace( 0, 100, 5, { -* 'endpoint': false -* }); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var linspace = require( '@stdlib/array-linspace' ); -* -* var arr = new Float64Array( 6 ); -* var out = linspace.assign( 0, 100, arr ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* var bool = ( arr === out ); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var linspace = require( '@stdlib/array-linspace' ); -* -* var arr = new Float64Array( 5 ); -* var out = linspace.assign( 0, 100, arr, { -* 'endpoint': false -* }); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a3aa0e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplexLike = require( '@stdlib/assert-is-complex-like' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var dtype = require( '@stdlib/complex-dtype' ); -var ctors = require( '@stdlib/array-typed-float-ctors' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var DEFAULTS = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); -var genreal = require( './generic_real.js' ); -var gencmplx = require( './generic_complex.js' ); -var typedreal = require( './typed_real.js' ); -var typedcmplx = require( './typed_complex.js' ); -var validate = require( './validate.js' ); -var defaults = require( './defaults.json' ); - - -// VARIABLES // - -var DEFAULT_COMPLEX_DTYPE = DEFAULTS.get( 'dtypes.complex_floating_point' ); - - -// MAIN // - -/** -* Generates a linearly spaced array over a specified interval. -* -* @param {(number|ComplexLike)} start - start of interval -* @param {(number|ComplexLike)} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {Options} [options] - options -* @param {string} [options.dtype] - output array data type -* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array -* @throws {TypeError} first argument must be either a real or complex number -* @throws {TypeError} second argument must be either a real or complex number -* @throws {TypeError} third argument must be a nonnegative integer -* @throws {TypeError} last argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} the output array data type must be a complex number data type or "generic" when either `start` or `stop` is a complex number -* @throws {TypeError} the output array data type must be a real or complex floating-point number data type or "generic" -* @returns {(Array|TypedArray|ComplexArray)} linearly spaced array -* -* @example -* var arr = linspace( 0, 100, 6, { -* 'dtype': 'generic' -* }); -* // returns [ 0, 20, 40, 60, 80, 100 ] -*/ -function linspace( start, stop, len ) { - var opts; - var ctor; - var err; - var out; - var dt1; - var dt2; - var flg; - - if ( typeof start === 'object' ) { - dt1 = dtype( start ); - if ( dt1 === null ) { - if ( !isComplexLike( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } - dt1 = 'complex128'; - } - flg = true; - } else if ( !isNumber( start ) || isnan( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } else { - dt1 = 'float64'; - } - if ( typeof stop === 'object' ) { - dt2 = dtype( stop ); - if ( dt2 === null ) { - if ( !isComplexLike( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } - dt2 = 'complex128'; - } - flg = true; - } else if ( !isNumber( stop ) || isnan( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } else { - dt2 = 'float64'; - } - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) ); - } - opts = { - 'endpoint': defaults.endpoint - }; - if ( dt1 === dt2 ) { - opts.dtype = dt1; // one of 'float64' || 'complex64' || 'complex128' - } else { - // If dtypes are different, then at least one is a complex number. According to type promotion rules, for all possible dtype permutations, the default output data type should be 'complex128'... - opts.dtype = DEFAULT_COMPLEX_DTYPE; - } - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - if ( opts.dtype === 'generic' ) { - if ( flg ) { - return gencmplx( dt1, start, dt2, stop, len, opts.endpoint ); - } - return genreal( start, stop, len, opts.endpoint ); - } - ctor = ctors( opts.dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a real or complex floating-point data type or "generic". Option: `%s`.', 'dtype', opts.dtype ) ); - } - out = new ctor( len ); - if ( opts.dtype === 'complex64' ) { - typedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( opts.dtype === 'complex128' ) { - typedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( flg ) { - throw new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or "generic".' ); - } - return typedreal( out, start, stop, len, opts.endpoint ); -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/typed_complex.js b/lib/typed_complex.js deleted file mode 100644 index 31bcbe6..0000000 --- a/lib/typed_complex.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); - - -// MAIN // - -/** -* Generates a linearly spaced complex number sequence over a specified interval and assigns the results to a provided output array strided view. -* -* @private -* @param {(Float32Array|Float64Array)} out - output array strided view -* @param {string} dt1 - start value data type -* @param {(number|ComplexLike)} start - start of interval -* @param {string} dt2 - stop value data type -* @param {(number|ComplexLike)} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {(Float32Array|Float64Array)} complex number array view -*/ -function linspace( out, dt1, start, dt2, stop, len, endpoint ) { - var re1; - var re2; - var im1; - var im2; - var dr; - var di; - var N; - var i; - var j; - - if ( len === 0 ) { - return out; - } - if ( dt1 === 'float64' ) { - re1 = start; - im1 = 0.0; - } else if ( dt1 === 'complex64' ) { - re1 = realf( start ); - im1 = imagf( start ); - } else { - re1 = real( start ); - im1 = imag( start ); - } - if ( dt2 === 'float64' ) { - re2 = stop; - im2 = 0.0; - } else if ( dt2 === 'complex64' ) { - re2 = realf( stop ); - im2 = imagf( stop ); - } else { - re2 = real( stop ); - im2 = imag( stop ); - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - out[ 0 ] = re2; - out[ 1 ] = im2; - } else { - out[ 0 ] = re1; - out[ 1 ] = im1; - } - return out; - } - out[ 0 ] = re1; - out[ 1 ] = im1; - - // Calculate the increments: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - dr = ( re2-re1 ) / N; - di = ( im2-im1 ) / N; - - // Generate linearly spaced complex numbers: - j = 2; - for ( i = 1; i < N; i++ ) { - out[ j ] = re1 + (dr*i); - out[ j+1 ] = im1 + (di*i); - j += 2; - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - out[ j ] = re2; - out[ j+1 ] = im2; - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/typed_real.js b/lib/typed_real.js deleted file mode 100644 index 9f8c069..0000000 --- a/lib/typed_real.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array. -* -* @private -* @param {TypedArray} out - output array -* @param {number} start - start of interval -* @param {number} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {TypedArray} linearly spaced array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var out = new Float64Array( 6 ); -* var arr = linspace( out, 0, 100, out.length, true ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var out = new Float64Array( 5 ); -* var arr = linspace( out, 0, 100, out.length, false ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -*/ -function linspace( out, start, stop, len, endpoint ) { - var N; - var d; - var i; - - if ( len === 0 ) { - return out; - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - out[ 0 ] = stop; - } else { - out[ 0 ] = start; - } - return out; - } - out[ 0 ] = start; - - // Calculate the increment: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - d = ( stop-start ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - out[ i ] = start + (d*i); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - out[ N ] = stop; - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index f0a3b3d..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.dtype] - output array data type -* @param {boolean} [options.endpoint] - boolean indicating whether the `stop` value in the output array -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'endpoint': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - if ( !isString( opts.dtype ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dtype', opts.dtype ) ); - } - } - if ( hasOwnProp( options, 'endpoint' ) ) { - opts.endpoint = options.endpoint; - if ( !isBoolean( opts.endpoint ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'endpoint', opts.endpoint ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 3a8eff2..0a939bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Generate a linearly spaced array over a specified interval.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-defaults": "^0.3.0", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/array-typed-float-ctors": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-string": "^0.2.2", - "@stdlib/complex-dtype": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", - "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-like-object": "^0.2.2", - "@stdlib/assert-is-complex128": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/utils-every-by": "^0.2.2", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdmath", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7b23e7d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/fixtures/complex_strided.js b/test/fixtures/complex_strided.js deleted file mode 100644 index 86a6d60..0000000 --- a/test/fixtures/complex_strided.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplex64 = require( '@stdlib/assert-is-complex64' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); - - -// MAIN // - -/** -* Converts an array of complex number objects to a interleaved strided array. -* -* @private -* @param {Array} arr - input array -* @returns {Array} output array -*/ -function toStrided( arr ) { - var out; - var z; - var i; - - out = []; - for ( i = 0; i < arr.length; i++ ) { - z = arr[ i ]; - if ( isComplex64( z ) ) { - out.push( realf( z ), imagf( z ) ); - } else { - out.push( real( z ), imag( z ) ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = toStrided; diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index c24096b..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,3533 +0,0 @@ -/* eslint-disable max-lines, max-len */ - -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var isComplex128 = require( '@stdlib/assert-is-complex128' ); -var isComplex64 = require( '@stdlib/assert-is-complex64' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var everyBy = require( '@stdlib/utils-every-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var toStrided = require( './fixtures/complex_strided.js' ); -var linspace = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -/** -* Returns an array-like object which uses accessors. -* -* @private -* @param {NonNegativeInteger} len - array length -* @returns {ArrayLikeObject} array-like object -*/ -function AccessorArray( len ) { - var self = this; - this.data = zeros( len ); - this.length = len; - this.set = setter; - this.get = getter; - return this; - - function setter( value, idx ) { - self.data[ idx ] = value; - } - - function getter( idx ) { - return self.data[ idx ]; - } -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if the first argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, new Float64Array( 10 ), {} ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, new Float64Array( 10 ), {} ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not an array-like object (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if the fourth argument is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, new Float64Array( 10 ), { - 'endpoint': value - }); - }; - } -}); - -tape( 'the function throws an error if provided one or more complex number arguments and the data type of the output array is not a complex number data type or "generic"', function test( t ) { - var values; - var x1; - var x2; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - values = [ - new Float64Array( 10 ), - new Float32Array( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( x1, x2, value ); - }; - } -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Float64Array( 0 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( out.length ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Float32Array( 0 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( out.length ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex128Array( 0 ); - actual = linspace( 0, 10, out ); - expected = new Float64Array( out.length*2 ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex64Array( 0 ); - actual = linspace( 0, 10, out ); - expected = new Float32Array( out.length*2 ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - - out = zeros( 0 ); - actual = linspace( 0, 10, out ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (complex; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 0 ); - actual = linspace( x1, x2, out ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (accessor array)', function test( t ) { - var expected; - var actual; - var out; - - out = new AccessorArray( 0 ); - actual = linspace( 0, 10, out ); - expected = zeros( out.length ); - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64)', function test( t ) { - var expected; - var actual; - var out; - - out = new Float64Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32)', function test( t ) { - var expected; - var actual; - var out; - - out = new Float32Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex128Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex64Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - - out = zeros( 1 ); - actual = linspace( 0, 10, out ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; accessor array)', function test( t ) { - var expected; - var actual; - var out; - - out = new AccessorArray( 1 ); - actual = linspace( 0, 10, out ); - expected = [ 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Float64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Float32Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Complex128Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Complex64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = zeros( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - opts = { - 'endpoint': true - }; - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - opts = { - 'endpoint': true - }; - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new AccessorArray( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Float64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 0.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Float32Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 0.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Complex128Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Complex64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = zeros( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new AccessorArray( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new Float64Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, 2.0, 4.0, 6.0, 8.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 8.0, 6.0, 4.0, 2.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x2, out, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'float64' - }; - - out = new Float64Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 6 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 6 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 6 ); - actual = linspace( x2, x2, out, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float32)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - out = new Float32Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 6 ); - actual = linspace( x2, x2, out ); - expected = new Float32Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = new Float32Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected =[ x1, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected =[ x2, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected =[ x1, -3.0, -1.0, 1.0, 3.0, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected =[ x2, 3.0, 1.0, -1.0, -3.0, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x2, out ); - expected =[ x2, x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = zeros( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 2.0, 4.0, 6.0, 8.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 8.0, 6.0, 4.0, 2.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x2, out, opts ); - expected = [ x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected =[ x1, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected =[ x2, x1 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected =[ x1, -3.0, -1.0, 1.0, 3.0, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected =[ x2, 3.0, 1.0, -1.0, -3.0, x1 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x2, out ); - expected =[ x2, x2, x2, x2, x2, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual.data[ actual.length-1 ], x2, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual.data[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 5.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 5.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 2.0, 4.0, 6.0, 8.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 8.0, 6.0, 4.0, 2.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x2, out, opts ); - expected = [ x2, x2, x2, x2, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual.data[ actual.length-1 ], x2, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual.data[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 0.0, 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = zeros( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), x2, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 5.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), x1, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 10.0, 10.0 ); - - opts = { - 'endpoint': false - }; - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 2.0, 2.0, 4.0, 4.0, 6.0, 6.0, 8.0, 8.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 8.0, 8.0, 6.0, 6.0, 4.0, 4.0, 2.0, 2.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; accessor arrays)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d083066..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var linspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof linspace.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 3fe3192..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,3267 +0,0 @@ -/* eslint-disable max-lines, max-len */ - -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var isComplex128 = require( '@stdlib/assert-is-complex128' ); -var isComplex64 = require( '@stdlib/assert-is-complex64' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var everyBy = require( '@stdlib/utils-every-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var toStrided = require( './fixtures/complex_strided.js' ); -var linspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, 10 ); - }; - } -}); - -tape( 'the function throws an error if the first argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, 10, {} ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, 10 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, 10, {} ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a nonnegative integer (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if the fourth argument is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, 10, { - 'endpoint': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized/unsupported data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'foo', - 'bar', - 'beep', - 'boop', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, 10, { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided one or more complex number arguments and the output data type is not a complex number data type or "generic"', function test( t ) { - var values; - var x1; - var x2; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - values = [ - 'float64', - 'float32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( x1, x2, 10, { - 'dtype': value - }); - }; - } -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; real)', function test( t ) { - var expected; - var actual; - - actual = linspace( 0, 10, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; complex)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; complex64)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 0 ); - expected = new Float32Array( [] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; complex-like)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64', - 'endpoint': false - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float64Array( [] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32', - 'endpoint': true - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float32Array( [] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128' - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64' - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float32Array( [] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( 0, 10, 0, opts ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (complex; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 0, opts ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; real)', function test( t ) { - var expected; - var actual; - - actual = linspace( 0, 10, 1 ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex64)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1 ); - expected = new Float32Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex-like)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( 0, 10, 1, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; real; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'endpoint': true - }; - - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; mixed; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float32Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex-like; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; real; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'endpoint': false - }; - - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 0.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; mixed; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float32Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex-like; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 0.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 0.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = [ 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; real)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ x1, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ x2, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6 ); - expected = new Float64Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; real; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ x1, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = new Float64Array( [ x1, 2.0, 4.0, 6.0, 8.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = new Float64Array( [ x2, 8.0, 6.0, 4.0, 2.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 5, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'float64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ x1, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'float32' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ x1, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ x2, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6, opts ); - expected = new Float32Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected =[ x1, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected =[ x2, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected =[ x1, -3.0, -1.0, 1.0, 3.0, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected =[ x2, 3.0, 1.0, -1.0, -3.0, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6, opts ); - expected =[ x2, x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ x1, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ x2, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = [ x1, 2.0, 4.0, 6.0, 8.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = [ x2, 8.0, 6.0, 4.0, 2.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 5, opts ); - expected = [ x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; mixed; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, 0.0, 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = new Float64Array( [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ realf( x1 ), imagf( x1 ), x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ x2, 0.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ x2, 0.0, 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ x1, 0.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ realf( x2 ), imagf( x2 ), x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 10.0, 10.0 ); - - opts = { - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 2.0, 2.0, 4.0, 4.0, 6.0, 6.0, 8.0, 8.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 8.0, 8.0, 6.0, 6.0, 4.0, 4.0, 2.0, 2.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex64)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - actual = linspace( x1, x2, 2 ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex128)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex-like)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 7ddd8fe..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,154 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `dtype` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dtype': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `endpoint` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'endpoint': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'dtype': 'float64', - 'endpoint': false - }; - opts = {}; - - expected = { - 'dtype': 'float64', - 'endpoint': false - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'extracts options' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'ignores unrecognized options' ); - - t.end(); -});