From f68cb755c94fa05aca205b161536a5cf696c6eb1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 04:17:58 +0000 Subject: [PATCH] Auto-generated commit --- .github/.keepalive | 1 + .github/workflows/benchmark.yml | 6 +- .github/workflows/cancel.yml | 3 +- .github/workflows/close_pull_requests.yml | 36 +- .github/workflows/examples.yml | 10 +- .github/workflows/npm_downloads.yml | 12 +- .github/workflows/productionize.yml | 42 +- .github/workflows/publish.yml | 15 +- .github/workflows/test.yml | 9 +- .github/workflows/test_bundles.yml | 27 +- .github/workflows/test_coverage.yml | 15 +- .github/workflows/test_install.yml | 9 +- README.md | 4 +- package.json | 6 +- test/dist/test.js | 4032 +++++++++++++++++++++ 15 files changed, 4159 insertions(+), 68 deletions(-) create mode 100644 .github/.keepalive create mode 100644 test/dist/test.js diff --git a/.github/.keepalive b/.github/.keepalive new file mode 100644 index 0000000..ec27a6f --- /dev/null +++ b/.github/.keepalive @@ -0,0 +1 @@ +2023-10-01T04:17:54.972Z diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 06a9a75..ab56cca 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -41,11 +41,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml index a00dbe5..3acd3a9 100644 --- a/.github/workflows/cancel.yml +++ b/.github/workflows/cancel.yml @@ -44,7 +44,8 @@ jobs: # Cancel existing workflow runs: - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 + # Pin action to full length commit SHA corresponding to v0.11.0 + uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 with: workflow_id: >- benchmark.yml, diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml index 72c754a..2858986 100644 --- a/.github/workflows/close_pull_requests.yml +++ b/.github/workflows/close_pull_requests.yml @@ -26,19 +26,29 @@ on: # Workflow jobs: jobs: + + # Define job to close all pull requests: run: + + # Define the type of virtual host machine on which to run the job: runs-on: ubuntu-latest + + # Define the sequence of job steps... steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file + + # Close pull request + - name: 'Close pull request' + # Pin action to full length commit SHA corresponding to v3.1.2 + uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 + with: + comment: | + Thank you for submitting a pull request. :raised_hands: + + We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). + + We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. + + Thank you again, and we look forward to receiving your contribution! :smiley: + + Best, + The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 7902a7d..c1c45e7 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -39,13 +39,15 @@ jobs: # Define the sequence of job steps... steps: - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 + # Checkout repository: + - name: 'Checkout repository' + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml index 12ecfa4..0bcebe7 100644 --- a/.github/workflows/npm_downloads.yml +++ b/.github/workflows/npm_downloads.yml @@ -45,12 +45,14 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 timeout-minutes: 10 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -84,7 +86,8 @@ jobs: # Upload the download data: - name: 'Upload data' - uses: actions/upload-artifact@v3 + # Pin action to full length commit SHA corresponding to v3.1.3 + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 with: # Define a name for the uploaded artifact (ensuring a unique name for each job): name: npm_downloads @@ -99,7 +102,8 @@ jobs: # Send data to events server: - name: 'Post data' - uses: distributhor/workflow-webhook@v3 + # Pin action to full length commit SHA corresponding to v3.0.3: + uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 env: webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml index 91f2b93..265afda 100644 --- a/.github/workflows/productionize.yml +++ b/.github/workflows/productionize.yml @@ -61,13 +61,15 @@ jobs: steps: # Checkout main branch of repository: - name: 'Checkout main branch' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: main # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -132,7 +134,8 @@ jobs: # Checkout the repository: - name: 'Checkout repository' if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: # Use the `production` branch: ref: production @@ -140,7 +143,8 @@ jobs: # Install Node.js: - name: 'Install Node.js' if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -184,7 +188,8 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Configure git: - name: 'Configure git' @@ -251,7 +256,8 @@ jobs: # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -334,7 +340,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -357,7 +364,8 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Configure git: - name: 'Configure git' @@ -416,7 +424,8 @@ jobs: # Install Node.js - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -505,7 +514,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -528,7 +538,8 @@ jobs: steps: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Configure git: - name: 'Configure git' @@ -595,7 +606,8 @@ jobs: # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -682,7 +694,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -706,7 +719,8 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: fetch-depth: 2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 474004b..b17435b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -61,11 +61,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -197,7 +199,8 @@ jobs: # Publish package to npm: - name: 'Publish package to npm' - uses: JS-DevTools/npm-publish@v2 + # Pin action to full length commit SHA corresponding to v2.2.2 + uses: JS-DevTools/npm-publish@fe72237be0920f7a0cafd6a966c9b929c9466e9b with: token: ${{ secrets.NPM_TOKEN }} access: public @@ -209,7 +212,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -230,7 +234,8 @@ jobs: # Cancel any running or queued workflow runs: - name: 'Cancel running or queued workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 + # Pin action to full length commit SHA corresponding to v0.11.0 + uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 with: workflow_id: >- benchmark.yml, diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1367a7..03cc4cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,11 +58,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -89,7 +91,8 @@ jobs: # Send status to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} diff --git a/.github/workflows/test_bundles.yml b/.github/workflows/test_bundles.yml index 172cb2d..0d26143 100644 --- a/.github/workflows/test_bundles.yml +++ b/.github/workflows/test_bundles.yml @@ -49,13 +49,15 @@ jobs: steps: # Checkout UMD branch of the repository: - name: 'Checkout branch with UMD build' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: umd # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 17 @@ -88,7 +90,8 @@ jobs: # Send notification to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -113,13 +116,15 @@ jobs: # Checkout ES modules branch of the repository: - name: 'Checkout branch with ESM build' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: esm # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 17 @@ -130,7 +135,8 @@ jobs: # Send notification to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -155,13 +161,15 @@ jobs: # Checkout Deno branch of the repository: - name: 'Checkout branch with Deno build' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 with: ref: deno # Install Deno: - name: 'Install Deno' - uses: denoland/setup-deno@v1 + # Pin action to full length commit SHA corresponding to v1.1.2 + uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 with: deno-version: vx.x.x @@ -172,7 +180,8 @@ jobs: # Send notification to Slack channel if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml index a73c515..5b2b1ea 100644 --- a/.github/workflows/test_coverage.yml +++ b/.github/workflows/test_coverage.yml @@ -46,11 +46,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -77,7 +79,8 @@ jobs: # Upload coverage report to Codecov: - name: 'Upload coverage to Codecov' id: upload - uses: codecov/codecov-action@v3 + # Pin action to full length commit SHA corresponding to v3.1.4 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d with: directory: reports/coverage flags: unittests @@ -106,7 +109,8 @@ jobs: # Send Slack notification if job fails: - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} @@ -115,7 +119,8 @@ jobs: # Send data to events server: - name: 'Post data' - uses: distributhor/workflow-webhook@v3 + # Pin action to full length commit SHA corresponding to v3.0.3: + uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 env: webhook_url: ${{ secrets.STDLIB_COVERAGE_URL }} webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 325cd48..30da063 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -58,11 +58,13 @@ jobs: # Checkout the repository: - name: 'Checkout repository' - uses: actions/checkout@v3 + # Pin action to full length commit SHA corresponding to v4.1.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # Install Node.js: - name: 'Install Node.js' - uses: actions/setup-node@v3 + # Pin action to full length commit SHA corresponding to v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: 16 timeout-minutes: 5 @@ -75,7 +77,8 @@ jobs: # Send Slack notification if job fails: - name: 'Send notification to Slack in case of failure' - uses: act10ns/slack@v2 + # Pin action to full length commit SHA corresponding to v2.0.0 + uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f with: status: ${{ job.status }} steps: ${{ toJson(steps) }} diff --git a/README.md b/README.md index 6ebbca6..fe57813 100644 --- a/README.md +++ b/README.md @@ -725,8 +725,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-ctor.svg [npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-ctor -[test-image]: https://github.com/stdlib-js/ndarray-base-ctor/actions/workflows/test.yml/badge.svg?branch=v0.1.0 -[test-url]: https://github.com/stdlib-js/ndarray-base-ctor/actions/workflows/test.yml?query=branch:v0.1.0 +[test-image]: https://github.com/stdlib-js/ndarray-base-ctor/actions/workflows/test.yml/badge.svg?branch=main +[test-url]: https://github.com/stdlib-js/ndarray-base-ctor/actions/workflows/test.yml?query=branch:main [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-ctor/main.svg [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-ctor?branch=main diff --git a/package.json b/package.json index 29c8417..d04603a 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0" }, "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", + "@stdlib/array-complex128": "^0.1.0", + "@stdlib/array-complex64": "^0.1.0", "@stdlib/array-float32": "^0.1.0", "@stdlib/array-float64": "^0.1.0", "@stdlib/assert-has-own-property": "^0.1.0", @@ -76,7 +76,7 @@ "@stdlib/complex-float32": "^0.1.0", "@stdlib/complex-float64": "^0.1.0", "@stdlib/math-base-special-floor": "^0.1.0", - "@stdlib/random-base-randu": "^0.0.8", + "@stdlib/random-base-randu": "^0.1.0", "proxyquire": "^2.0.0", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", diff --git a/test/dist/test.js b/test/dist/test.js new file mode 100644 index 0000000..f1d8636 --- /dev/null +++ b/test/dist/test.js @@ -0,0 +1,4032 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var Float64Array = require( '@stdlib/array-float64' ); +var Uint8Array = require( '@stdlib/array-uint8' ); +var Complex64Array = require( '@stdlib/array-complex64' ); +var Complex128Array = require( '@stdlib/array-complex128' ); +var Complex64 = require( '@stdlib/complex-float32' ); +var Complex128 = require( '@stdlib/complex-float64' ); +var hasOwnProp = require( '@stdlib/assert-has-own-property' ); +var hasProp = require( '@stdlib/assert-has-property' ); +var instanceOf = require( '@stdlib/assert-instance-of' ); +var isFunction = require( '@stdlib/assert-is-function' ); +var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; +var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; +var isPlainObject = require( '@stdlib/assert-is-plain-object' ); +var isDataView = require( '@stdlib/assert-is-dataview' ); +var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); +var real = require( '@stdlib/complex-real' ); +var imag = require( '@stdlib/complex-imag' ); +var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; +var modes = require( '@stdlib/ndarray-index-modes' ).enum; +var orders = require( '@stdlib/ndarray-orders' ).enum; +var ndarray = require( './../../dist' ); + + +// VARIABLES // + +var DTYPES = dtypes(); +var MODES = modes(); +var ORDERS = orders(); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function is an ndarray constructor', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = new ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); + t.end(); +}); + +tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = new ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); + t.end(); +}); + +tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); + t.strictEqual( arr.byteLength, null, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); + t.strictEqual( arr.byteLength, null, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); + t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); + t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); + t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); + t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); + t.strictEqual( arr.data, buffer, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); + t.strictEqual( arr.data, buffer, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); + t.strictEqual( arr.data, buffer, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); + t.strictEqual( arr.dtype, dtype, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); + t.strictEqual( arr.dtype, dtype, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); + t.strictEqual( arr.dtype, dtype, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); + t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); + + t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); + + t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); + t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); + + t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); + + t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 4 ]; + order = 'row-major'; + strides = [ 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); + t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); + + t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); + + t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); + t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); + + t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); + + t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); + shape = [ 2, 2, 2 ]; + order = 'column-major'; + strides = [ 4, 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); + t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); + + t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); + + t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); + t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.length, buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.length, buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.length, buffer.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); + t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); + t.strictEqual( arr.ndims, shape.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); + t.strictEqual( arr.ndims, shape.length, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.offset, offset, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.offset, offset, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); + t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); + t.strictEqual( arr.offset, offset, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); + t.strictEqual( arr.order, order, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); + t.strictEqual( arr.order, order, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); + t.strictEqual( arr.order, order, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'column-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); + t.strictEqual( arr.order, order, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); + t.notEqual( arr.shape, shape, 'returns a copy' ); + t.deepEqual( arr.shape, shape, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'column-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); + t.notEqual( arr.shape, shape, 'returns a copy' ); + t.deepEqual( arr.shape, shape, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); + t.notEqual( arr.strides, strides, 'returns a copy' ); + t.deepEqual( arr.strides, strides, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0 ] ); + shape = []; + order = 'column-major'; + strides = [ 0 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); + t.notEqual( arr.strides, strides, 'returns a copy' ); + t.deepEqual( arr.strides, strides, 'has expected value' ); + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, -1 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, -1 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + v = arr.get( 0, 0 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.get( 0, 1 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.get( 1, 0 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.get( 1, 1 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, 2 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, -2 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + v = arr.get( 0, 0 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.get( 0, 1 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.get( 1, 0 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.get( 1, 1 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( arr.get ), true, 'has method' ); + + t.strictEqual( arr.get(), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, -1 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, -1 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2, 1 ]; + order = 'row-major'; + strides = [ 4, 1, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, -1 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len + shape = [ 2, 2, 1 ]; + order = 'row-major'; + strides = [ 4, 1, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, 2 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, -2 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2, 1 ]; + order = 'column-major'; + strides = [ 1, 4, 8 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, -2 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 7.0, 'returns expected value' ); + t.strictEqual( imag( v ), 8.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len + shape = [ 2, 2, 1 ]; + order = 'column-major'; + strides = [ 1, 4, 8 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v ), 2.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 3.0, 'returns expected value' ); + t.strictEqual( imag( v ), 4.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iget ), true, 'has method' ); + + v = arr.iget(); + t.strictEqual( real( v ), 5.0, 'returns expected value' ); + t.strictEqual( imag( v ), 6.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, -1 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, -1 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); + arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); + arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); + arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); + + v = arr.get( 0, 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.get( 0, 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.get( 1, 0 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.get( 1, 1 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, 2 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, -2 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, 5.0 ); + arr.set( 0, 1, 6.0 ); + arr.set( 1, 0, 7.0 ); + arr.set( 1, 1, 8.0 ); + + t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); + arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); + arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); + arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); + + v = arr.get( 0, 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.get( 0, 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.get( 1, 0 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.get( 1, 1 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( arr.set ), true, 'has method' ); + + arr.set( 5.0 ); + + t.strictEqual( arr.get(), 5.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, -1 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, -1 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; + shape = [ 2, 2, 1 ]; + order = 'row-major'; + strides = [ 4, 1, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, -5.0 ); + arr.iset( 1, -6.0 ); + arr.iset( 2, -7.0 ); + arr.iset( 3, -8.0 ); + + t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( 9.0, 10.0 ) ); + arr.iset( 1, new Complex64( 11.0, 12.0 ) ); + arr.iset( 2, new Complex64( 13.0, 14.0 ) ); + arr.iset( 3, new Complex64( 15.0, 16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( 9.0, 10.0 ) ); + arr.iset( 1, new Complex64( 11.0, 12.0 ) ); + arr.iset( 2, new Complex64( 13.0, 14.0 ) ); + arr.iset( 3, new Complex64( 15.0, 16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ -2, -1 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( 9.0, 10.0 ) ); + arr.iset( 1, new Complex64( 11.0, 12.0 ) ); + arr.iset( 2, new Complex64( 13.0, 14.0 ) ); + arr.iset( 3, new Complex64( 15.0, 16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len + shape = [ 2, 2, 1 ]; + order = 'row-major'; + strides = [ 4, 1, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( -9.0, -10.0 ) ); + arr.iset( 1, new Complex64( -11.0, -12.0 ) ); + arr.iset( 2, new Complex64( -13.0, -14.0 ) ); + arr.iset( 3, new Complex64( -15.0, -16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), -9.0, 'returns expected value' ); + t.strictEqual( imag( v ), -10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), -11.0, 'returns expected value' ); + t.strictEqual( imag( v ), -12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), -13.0, 'returns expected value' ); + t.strictEqual( imag( v ), -14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), -15.0, 'returns expected value' ); + t.strictEqual( imag( v ), -16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, 2 ]; + offset = 1; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, -2 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, 5.0 ); + arr.iset( 1, 6.0 ); + arr.iset( 2, 7.0 ); + arr.iset( 3, 8.0 ); + + t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; + shape = [ 2, 2, 1 ]; + order = 'column-major'; + strides = [ 1, 4, 8 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, -5.0 ); + arr.iset( 1, -6.0 ); + arr.iset( 2, -7.0 ); + arr.iset( 3, -8.0 ); + + t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); + t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); + t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); + t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); + + t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, 2 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( 9.0, 10.0 ) ); + arr.iset( 1, new Complex64( 11.0, 12.0 ) ); + arr.iset( 2, new Complex64( 13.0, 14.0 ) ); + arr.iset( 3, new Complex64( 15.0, 16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ 1, -2 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( 9.0, 10.0 ) ); + arr.iset( 1, new Complex64( 11.0, 12.0 ) ); + arr.iset( 2, new Complex64( 13.0, 14.0 ) ); + arr.iset( 3, new Complex64( 15.0, 16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( 9.0, 10.0 ) ); + arr.iset( 1, new Complex64( 11.0, 12.0 ) ); + arr.iset( 2, new Complex64( 13.0, 14.0 ) ); + arr.iset( 3, new Complex64( 15.0, 16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), 9.0, 'returns expected value' ); + t.strictEqual( imag( v ), 10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), 11.0, 'returns expected value' ); + t.strictEqual( imag( v ), 12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), 13.0, 'returns expected value' ); + t.strictEqual( imag( v ), 14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), 15.0, 'returns expected value' ); + t.strictEqual( imag( v ), 16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len + shape = [ 2, 2, 1 ]; + order = 'column-major'; + strides = [ 4, 1, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( 0, new Complex64( -9.0, -10.0 ) ); + arr.iset( 1, new Complex64( -11.0, -12.0 ) ); + arr.iset( 2, new Complex64( -13.0, -14.0 ) ); + arr.iset( 3, new Complex64( -15.0, -16.0 ) ); + + v = arr.iget( 0 ); + t.strictEqual( real( v ), -9.0, 'returns expected value' ); + t.strictEqual( imag( v ), -10.0, 'returns expected value' ); + v = arr.iget( 1 ); + t.strictEqual( real( v ), -11.0, 'returns expected value' ); + t.strictEqual( imag( v ), -12.0, 'returns expected value' ); + v = arr.iget( 2 ); + t.strictEqual( real( v ), -13.0, 'returns expected value' ); + t.strictEqual( imag( v ), -14.0, 'returns expected value' ); + v = arr.iget( 3 ); + t.strictEqual( real( v ), -15.0, 'returns expected value' ); + t.strictEqual( imag( v ), -16.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( -5.0 ); + + t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); + + t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var v; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); + t.strictEqual( isFunction( arr.iset ), true, 'has method' ); + + arr.iset( new Complex64( -5.0, -6.0 ) ); + + v = arr.iget(); + t.strictEqual( real( v ), -5.0, 'returns expected value' ); + t.strictEqual( imag( v ), -6.0, 'returns expected value' ); + + t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex128'; + buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = new Array( 1e4 ); + shape = [ buffer.length ]; + order = 'row-major'; + strides = [ 1 ]; + offset = 0; + + buffer[ 0 ] = 1.0; + buffer[ 1 ] = 2.0; + buffer[ 2 ] = 3.0; + buffer[ buffer.length-3 ] = 4.0; + buffer[ buffer.length-2 ] = 5.0; + buffer[ buffer.length-1 ] = 6.0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( 1e4 ); + shape = [ buffer.length ]; + order = 'row-major'; + strides = [ 1 ]; + offset = 0; + + buffer.set( new Complex64( 1.0, 1.0 ), 0 ); + buffer.set( new Complex64( 2.0, 2.0 ), 1 ); + buffer.set( new Complex64( 3.0, 3.0 ), 2 ); + buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); + buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); + buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex128'; + buffer = new Complex128Array( 1e4 ); + shape = [ buffer.length ]; + order = 'row-major'; + strides = [ 1 ]; + offset = 0; + + buffer.set( new Complex128( 1.0, 1.0 ), 0 ); + buffer.set( new Complex128( 2.0, 2.0 ), 1 ); + buffer.set( new Complex128( 3.0, 3.0 ), 2 ); + buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); + buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); + buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toString ), true, 'has method' ); + + expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; + actual = arr.toString(); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); + + expected = { + 'type': 'ndarray', + 'dtype': 'float64', + 'data': [ 3.0, 4.0, 5.0, 6.0 ], + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'order': 'row-major', + 'flags': { + 'READONLY': false + } + }; + actual = arr.toJSON(); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = [ 2, 2 ]; + order = 'column-major'; + strides = [ -1, -2 ]; + offset = 3; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); + + expected = { + 'type': 'ndarray', + 'dtype': 'generic', + 'data': [ 4.0, 3.0, 2.0, 1.0 ], + 'shape': [ 2, 2 ], + 'strides': [ 1, 2 ], + 'order': 'column-major', + 'flags': { + 'READONLY': false + } + }; + actual = arr.toJSON(); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'complex64'; + buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 0; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); + + expected = { + 'type': 'ndarray', + 'dtype': 'complex64', + 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'order': 'row-major', + 'flags': { + 'READONLY': false + } + }; + actual = arr.toJSON(); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + + dtype = 'generic'; + buffer = [ 1.0, 2.0, 3.0, 4.0 ]; + shape = []; + order = 'row-major'; + strides = [ 0 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); + t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); + + expected = { + 'type': 'ndarray', + 'dtype': 'generic', + 'data': [ 3.0 ], + 'shape': [], + 'strides': [ 0 ], + 'order': 'row-major', + 'flags': { + 'READONLY': false + } + }; + actual = arr.toJSON(); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { + /* eslint-disable no-underscore-dangle */ + var expected; + var strides; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var bytes; + var arr; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); + t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); + + expected = { + 'dtype': DTYPES[ 'float64' ], + 'ndims': shape.length, + 'shape': shape, + 'strides': strides, + 'offset': offset, + 'order': ORDERS[ 'row-major' ], + 'mode': MODES[ 'throw' ], + 'nsubmodes': 1, + 'submodes': [ MODES[ 'throw' ] ], + 'flags': 0 + }; + + arr.__meta_dataview__ = null; + actual = arr.__array_meta_dataview__(); + arr.__meta_dataview__ = null; + + t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); + t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); + + bytes = new Uint8Array( actual.buffer ); + if ( IS_LITTLE_ENDIAN ) { + t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); + t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); + t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); + t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); + t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); + t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); + t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); + t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); + t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); + t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); + t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); + t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); + t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); + } else { + t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); + t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); + t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); + t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); + t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); + t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); + t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); + t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); + t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); + t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); + t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); + t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); + t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); + } + t.end(); + + /* eslint-enable no-underscore-dangle */ +}); + +tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { + /* eslint-disable no-underscore-dangle */ + var expected; + var strides; + var ndarray; + var actual; + var buffer; + var offset; + var dtype; + var order; + var shape; + var bytes; + var arr; + + ndarray = proxyquire( './../dist/main.js', { + '@stdlib/assert-has-bigint-support': hasSupport + }); + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); + t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); + t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); + + expected = { + 'dtype': DTYPES[ 'float64' ], + 'ndims': shape.length, + 'shape': shape, + 'strides': strides, + 'offset': offset, + 'order': ORDERS[ 'row-major' ], + 'mode': MODES[ 'throw' ], + 'nsubmodes': 1, + 'submodes': [ MODES[ 'throw' ] ], + 'flags': 0 + }; + + arr.__meta_dataview__ = null; + actual = arr.__array_meta_dataview__(); + arr.__meta_dataview__ = null; + + t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); + t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); + + bytes = new Uint8Array( actual.buffer ); + if ( IS_LITTLE_ENDIAN ) { + t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); + t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); + t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); + t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); + t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); + t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); + t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); + t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); + t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); + t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); + t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); + t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); + t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); + } else { + t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); + t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); + t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); + t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); + t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); + t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); + t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); + t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); + t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); + t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); + t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); + t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); + t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); + } + t.end(); + + function hasSupport() { + return false; + } + + /* eslint-enable no-underscore-dangle */ +}); + +tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { + /* eslint-disable no-underscore-dangle */ + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var dv1; + var dv2; + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + arr.__meta_dataview__ = null; + dv1 = arr.__array_meta_dataview__(); + dv2 = arr.__array_meta_dataview__(); + arr.__meta_dataview__ = null; + + t.strictEqual( dv1, dv2, 'returns cached meta data' ); + + t.end(); + + /* eslint-enable no-underscore-dangle */ +}); + +tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { + /* eslint-disable no-underscore-dangle */ + var ndarray; + var strides; + var buffer; + var offset; + var dtype; + var order; + var shape; + var arr; + var dv1; + var dv2; + + ndarray = proxyquire( './../dist/main.js', { + '@stdlib/assert-has-bigint-support': hasSupport + }); + + dtype = 'float64'; + buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + shape = [ 2, 2 ]; + order = 'row-major'; + strides = [ 2, 1 ]; + offset = 2; + + arr = ndarray( dtype, buffer, shape, strides, offset, order ); + + arr.__meta_dataview__ = null; + dv1 = arr.__array_meta_dataview__(); + dv2 = arr.__array_meta_dataview__(); + arr.__meta_dataview__ = null; + + t.strictEqual( dv1, dv2, 'returns cached meta data' ); + + t.end(); + + function hasSupport() { + return false; + } + + /* eslint-enable no-underscore-dangle */ +});