From e542cd52b8dd32874d21b1a42c2be860269e435e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 06:27:31 +0000 Subject: [PATCH 01/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index ae01502..c084d40 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.1", "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-define-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.1", From ae4cdd54c584aabc0a6194747cf12fe43068d4e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 06:28:21 +0000 Subject: [PATCH 02/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 52 files changed, 4865 insertions(+), 5431 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/reviver-float64]: https://github.com/stdlib-js/complex-reviver-float64 +[@stdlib/complex/reviver-float64]: https://github.com/stdlib-js/complex-reviver-float64/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index af99f9e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){ -function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v -});var a=o(function(d,u){ -function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c -});var h=o(function(q,f){ -var l=require('@stdlib/assert-is-number/dist').isPrimitive,m=require('@stdlib/utils-define-property/dist'),i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError(p('null0G'));if(!l(e))throw new TypeError(p('null3e',e));if(!l(r))throw new TypeError(p('null3f',r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t -});var E=h();module.exports=E; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f7f0d58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index c084d40..edc5901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.0", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-define-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 7f343ae..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..339edab --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From dd7fe386c8754af05e4855ae32cce6714d00d1de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 19:29:07 +0000 Subject: [PATCH 03/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index ae01502..c084d40 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.1", "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-define-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.1", From 8e377c956fed64d9738c18a4a7d9db4bd05d882f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 19:31:26 +0000 Subject: [PATCH 04/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f7f0d58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 339edab..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From af52b7b178545cf3b03affbd9ceef551d0372685 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 19:31:43 +0000 Subject: [PATCH 05/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 52 files changed, 4865 insertions(+), 5431 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index af99f9e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){ -function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v -});var a=o(function(d,u){ -function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c -});var h=o(function(q,f){ -var l=require('@stdlib/assert-is-number/dist').isPrimitive,m=require('@stdlib/utils-define-property/dist'),i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError(p('null0G'));if(!l(e))throw new TypeError(p('null3e',e));if(!l(r))throw new TypeError(p('null3f',r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t -});var E=h();module.exports=E; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f7f0d58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index c084d40..edc5901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.0", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-define-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..339edab --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 2a79dba656d24ef056cdab789e6adda529613bb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Jun 2024 16:16:25 +0000 Subject: [PATCH 06/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index f332bc4..5641209 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.1", "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-define-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.1", From 549488ff325e23df7e6f1a4ce7924aaa14bcac2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Jun 2024 16:16:58 +0000 Subject: [PATCH 07/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f7f0d58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 339edab..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 08d1d158de0902f00d37f32aae755b0e58855441 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Jun 2024 16:17:15 +0000 Subject: [PATCH 08/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 75 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 52 files changed, 4865 insertions(+), 5515 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f7f0d58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 5641209..7141928 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.1", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-define-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..339edab --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From f5f62ec43d951e84eba867b137251f05fc5af324 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Jun 2024 16:17:45 +0000 Subject: [PATCH 09/92] Update README.md for ESM bundle v0.0.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64b2a64..3a74106 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@esm/index.mjs'; +import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.0.1-esm/index.mjs'; ``` #### Complex128( real, imag ) @@ -200,7 +200,7 @@ To [revive][mdn-json-parse] a `Complex128` number from a [JSON][json] `string`, - - - - From 7a581a2486249163b5a2501cbb37731b3c1d7e61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:48:48 +0000 Subject: [PATCH 13/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 70 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 52 files changed, 4865 insertions(+), 5510 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 56d740f..8ac0081 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 8ac449cdc0f4b1e18a9caa028c2df00ab04fba41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:55:43 +0000 Subject: [PATCH 14/92] Update README.md for ESM bundle v0.0.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5683738..969b750 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@esm/index.mjs'; +import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.0.2-esm/index.mjs'; ``` #### Complex128( real, imag ) @@ -200,7 +200,7 @@ To [revive][mdn-json-parse] a `Complex128` number from a [JSON][json] `string`, - - - - From 7a38c676059e7353ae0a76916f1b904c67dc4c23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 17:23:58 +0000 Subject: [PATCH 18/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 52 files changed, 4865 insertions(+), 5520 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index b196b44..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 28a69aeeeb7266a2e4fea6948c887f84d7552fe6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 17:24:16 +0000 Subject: [PATCH 19/92] Update README.md for ESM bundle v0.0.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41b6f13..5da4070 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@esm/index.mjs'; +import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.0.3-esm/index.mjs'; ``` #### Complex128( real, imag ) @@ -200,7 +200,7 @@ To [revive][mdn-json-parse] a `Complex128` number from a [JSON][json] `string`, - - - - From b4cbd0d9daa4f1e9d594d810d04c907fa7efc84b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 06:29:13 +0000 Subject: [PATCH 23/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 68 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 53 files changed, 4865 insertions(+), 5511 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9ae0f0f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T02:21:36.881Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 064f726c3b1c146500c098241bab5af94297ecb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 17:59:05 +0000 Subject: [PATCH 24/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 3c0d290831d31dcb677f738c1c7faf8aaf5940bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 20:06:17 +0000 Subject: [PATCH 25/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7be78c9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c19c4a776150265419f4bbbae80d2237397673dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 20:06:29 +0000 Subject: [PATCH 26/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 53 files changed, 4865 insertions(+), 5523 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index eaaf8fb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T17:18:57.614Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 539db065f840bd4707a1dce392c134b4e0361cb5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 03:27:33 +0000 Subject: [PATCH 27/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 507bdac042e5578536a9353670a17223108921ee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 06:25:41 +0000 Subject: [PATCH 28/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7be78c9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 43c546ea90cfc4b4395bcdd9f4646ad581df24c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 06:25:54 +0000 Subject: [PATCH 29/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 53 files changed, 4865 insertions(+), 5523 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 38bc761..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T02:30:54.088Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 04e36762ab4541deaf3b86abede3e76ce4e38597 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 03:32:45 +0000 Subject: [PATCH 30/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 4d034c0f91255756b4e902c24f47843c3c10fc9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 06:24:56 +0000 Subject: [PATCH 31/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7be78c9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d8f9f52246e431446e3dcf70dd6024fdb1257995 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 06:25:09 +0000 Subject: [PATCH 32/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 53 files changed, 4865 insertions(+), 5523 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3c90624..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T02:39:37.264Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From dfe9833248c68507a94b525fe67d8d073edcf4c7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 03:31:56 +0000 Subject: [PATCH 33/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 07c45b99b53a38a9e5b4625bb9461b3ead8c3fc9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 06:02:28 +0000 Subject: [PATCH 34/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7be78c9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1015cb70a03f8bfb3a1434fea204810a9b51530e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 06:02:50 +0000 Subject: [PATCH 35/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 53 files changed, 4865 insertions(+), 5523 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a843d8c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T02:39:42.106Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 360b7eb35f07949bb42e46e8fceccfc90648acde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 03:38:42 +0000 Subject: [PATCH 36/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From e0aebf4f8b3f486e4bb91a595860dd8fd73891cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 06:33:35 +0000 Subject: [PATCH 37/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7be78c9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e9778cb0486f8fa4f83ccef13ea40783e7c34619 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 06:33:52 +0000 Subject: [PATCH 38/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5628 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0a95541..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T02:45:37.274Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7be78c9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From ea8e4d14a2f05b228ac5df3c3d23f5fbfa0585cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:44:52 +0000 Subject: [PATCH 39/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 817257e6859899ec1a17cb3db284db4148157569 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:58:04 +0000 Subject: [PATCH 40/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7be78c9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5281171724d0c78c2765b73204c885ad5b5a701d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:58:24 +0000 Subject: [PATCH 41/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5628 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6afad1f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-13T01:42:30.387Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index feddf6b..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..836c080 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 476ef832631190aa0e298005a04f41c5ae8c04d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 00:28:16 +0000 Subject: [PATCH 42/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From ceeeb69f348270e6941f1a9f0793094df07c3908 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 00:29:42 +0000 Subject: [PATCH 43/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 836c080..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aa031c7cd5492041dd18bdb4a2cd9a2b97d1120c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 00:29:59 +0000 Subject: [PATCH 44/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5631 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9c37fc4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T00:27:40.851Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..836c080 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 3a4c2b0bef4bd6576d8b2e1571684702e0d0f5d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:43:18 +0000 Subject: [PATCH 45/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 563c5c8f6ef2127bafae7e071f6d19c30309a728 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:09:23 +0000 Subject: [PATCH 46/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 836c080..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2eb1211e0ec9c9fcb02c1d9fe22fa1043efe553e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:09:45 +0000 Subject: [PATCH 47/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5631 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 492ee57..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:28:48.948Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..836c080 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 07b9d843ee90fcf4e542e091c3835c304b931145 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:34:08 +0000 Subject: [PATCH 48/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From cba5e25e89cd963313b3cd10a4a6a5a3cf8da740 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:51:03 +0000 Subject: [PATCH 49/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 836c080..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 28fb53229b815bc799ebcd13705e3a04b95b5e2f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:51:21 +0000 Subject: [PATCH 50/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5631 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c22c0c1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-07T01:28:21.772Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..836c080 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From a508bbacd7962ed97bfb229e8aca154d61804ac9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:33:45 +0000 Subject: [PATCH 51/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From 57b27392a8dd8727c9ec887a9abb492e169568a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 02:12:13 +0000 Subject: [PATCH 52/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 836c080..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cab26aaeb3d9379678c2049604b31c3630c4750f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 02:12:28 +0000 Subject: [PATCH 53/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 80 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5631 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3fb9f9a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T01:21:58.944Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..836c080 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index afb9dcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 7aa8abeef82846eab17d45f8ef2c38b0c9a3bc78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 Aug 2025 00:46:29 +0000 Subject: [PATCH 54/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index f1552fe..385f257 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var defineProperty = require( '@stdlib/utils-define-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } defineProperty( this, 're', { 'configurable': false, diff --git a/package.json b/package.json index 0ce803d..548db53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-property": "^0.2.4", "@stdlib/utils-library-manifest": "^0.2.2", From db842b0ab4625b5d2dc5e2006c080598f6d4b800 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 Aug 2025 00:48:21 +0000 Subject: [PATCH 55/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 836c080..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5bec0bd9f8440a51343424bd9352665ded6fdb31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 Aug 2025 00:48:44 +0000 Subject: [PATCH 56/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 114 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 158 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 54 files changed, 4865 insertions(+), 5665 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ee44c9a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-08-18T00:44:31.388Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c2ec8e9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function v(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=v});var a=o(function(d,u){"use strict";function c(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=c});var h=o(function(q,f){"use strict";var l=require("@stdlib/assert-is-number").isPrimitive,m=require("@stdlib/utils-define-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),p=require("@stdlib/string-format"),b=s(),y=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!l(e))throw new TypeError(p("invalid argument. Real component must be a number. Value: `%s`.",e));if(!l(r))throw new TypeError(p("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return m(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:e}),m(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",b);i(t.prototype,"toJSON",y);f.exports=t});var E=h();module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e99c6f0..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar defineProperty = require( '@stdlib/utils-define-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,+BAAgC,EAC1DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASM,CACV,CAAC,EACDN,EAAgB,KAAM,KAAM,CAC3B,aAAgB,GAChB,WAAc,GACd,SAAY,GACZ,MAASO,CACV,CAAC,EACM,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IC3HjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "defineProperty", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..836c080 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a42d8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 385f257..0000000 --- a/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - defineProperty( this, 're', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': real - }); - defineProperty( this, 'im', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': imag - }); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 548db53..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-property": "^0.2.4", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cebcf77 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From bd5f6892ad80aaf7bbc942fe2dd07d43d46945d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Dec 2025 05:51:04 +0000 Subject: [PATCH 57/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9a2b076..25791b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index aa4943e..50c887a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-read-only-property": "^0.2.2", "@stdlib/utils-library-manifest": "^0.2.2", From 15a9282c8befcd3084726f27c647f786ea38115b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Dec 2025 05:51:24 +0000 Subject: [PATCH 58/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 836c080..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-property@v0.2.4-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!e(r))throw new TypeError(i("null3e",r));if(!e(n))throw new TypeError(i("null3f",n));return t(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),t(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:n}),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i"})),r(s.prototype,"toJSON",(function(){var e={type:"Complex128"};return e.re=this.re,e.im=this.im,e}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a42d8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport defineProperty from '@stdlib/utils-define-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","defineProperty","configurable","enumerable","writable","value","setReadOnly","prototype","str","re","im","out"],"mappings":";;maA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAcxC,OAZAK,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAASV,IAEVM,EAAgBJ,KAAM,KAAM,CAC3BK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZC,MAAST,IAEHC,IACR,CAcAS,EAAaZ,EAAY,oBAAqB,GAgB9CY,EAAaZ,EAAWa,UAAW,oBAAqB,GAgBxDD,EAAaZ,EAAWa,UAAW,aAAc,IAgBjDD,EAAaZ,EAAWa,UAAW,YC1GnC,WAEC,IAAIC,EAAM,GAAKX,KAAKY,GAOpB,OANKZ,KAAKa,GAAK,EACdF,GAAO,OAAUX,KAAKa,GAEtBF,GAAO,MAAQX,KAAKa,GAErBF,GAAO,GAER,IDoHAF,EAAaZ,EAAWa,UAAW,UE9HnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKZ,KAAKY,GACdE,EAAID,GAAKb,KAAKa,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cebcf77..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4916d124c6811fdd243f5ce6a9599f9ee7ec373e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Dec 2025 05:51:37 +0000 Subject: [PATCH 59/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 116 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 75 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 148 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 213 - 53 files changed, 4865 insertions(+), 5661 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -239,359 +230,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -625,7 +264,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -694,13 +333,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index afb404b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(r,t){return function(){return t||r((t={exports:{}}).exports,t),t.exports}};var s=o(function(S,n){"use strict";function c(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i",r}n.exports=c});var a=o(function(d,u){"use strict";function y(){var r={};return r.type="Complex128",r.re=this.re,r.im=this.im,r}u.exports=y});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),l=s(),f=a();function e(r,t){if(!(this instanceof e))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(r))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",r));if(!m(t))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",t));return p(this,"re",r),p(this,"im",t),this}i(e,"BYTES_PER_ELEMENT",8);i(e.prototype,"BYTES_PER_ELEMENT",8);i(e.prototype,"byteLength",16);i(e.prototype,"toString",l);i(e.prototype,"toJSON",f);v.exports=e});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 2572270..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAcAN,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,ICjHjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 45c5c8e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,75 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdd96c5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0c89cda --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAcAK,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YChGnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,ID0GAF,EAAaR,EAAWS,UAAW,UEpHnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 25791b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,148 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 50c887a..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dcba0cd --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index eb8cd50..0000000 --- a/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From d808ccfc215f2d79e98214346ba2105f5d6d59f5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Dec 2025 05:28:21 +0000 Subject: [PATCH 60/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 761a6d2..3f2bf89 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index aa4943e..50c887a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-read-only-property": "^0.2.2", "@stdlib/utils-library-manifest": "^0.2.2", From 578c34dd206fc1f1e498e9486f51fd7469c9bb01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Dec 2025 05:28:36 +0000 Subject: [PATCH 61/92] Remove files --- index.d.ts | 111 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4958 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 61884d8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdd96c5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0c89cda..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAcAK,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YChGnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,ID0GAF,EAAaR,EAAWS,UAAW,UEpHnC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dcba0cd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 407a9deafce79020f04459a6cc926154885cf9e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Dec 2025 05:29:00 +0000 Subject: [PATCH 62/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 139 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 53 files changed, 4865 insertions(+), 5719 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..36fc3f3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 50c887a..8b4e0a4 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.3", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c485f82 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 1b770e3266659c9a94aabd172580e21631f27428 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 21:11:39 +0000 Subject: [PATCH 63/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 761a6d2..3f2bf89 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index f29ea10..b7d398d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.2", "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-read-only-property": "^0.2.2", "@stdlib/utils-library-manifest": "^0.2.3", From 824095e74a556777a13b07288f6cf20ac6f9850a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 21:40:28 +0000 Subject: [PATCH 64/92] Remove files --- index.d.ts | 120 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4967 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 4a6e587..0000000 --- a/index.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Constructor name. - * - * @example - * var str = Complex128.name; - * // returns 'Complex128' - */ - static readonly name: 'Complex128'; - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 36fc3f3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8cca46d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c485f82..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 647fbfe23fd9312a30d1c3f9b120536576fb8e19 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 21:40:56 +0000 Subject: [PATCH 65/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 139 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 53 files changed, 4865 insertions(+), 5819 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..11cd7a7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index b7d398d..2440c70 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.0", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c485f82 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 03a840763084d070e0028a8d1580f9f366640964 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 22:12:44 +0000 Subject: [PATCH 66/92] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca81644..70286e5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@esm/index.mjs'; +import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.1.0-esm/index.mjs'; ``` #### Complex128( real, imag ) @@ -209,7 +209,7 @@ To [revive][mdn-json-parse] a `Complex128` number from a [JSON][json] `string`, - - - - From fa7ba6dfb7d3745b946c1e06ae39c1cb821caa50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Feb 2026 06:32:30 +0000 Subject: [PATCH 70/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 149 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 53 files changed, 4865 insertions(+), 5829 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..02c85a7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0a84a64 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;iZA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 355c2ed..0b042d6 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2bb6666 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From f6fb88d340a973ace71af2d34b74e4879a862c42 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Feb 2026 06:32:51 +0000 Subject: [PATCH 71/92] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9ae245..cebffd5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@esm/index.mjs'; +import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.1.1-esm/index.mjs'; ``` #### Complex128( real, imag ) @@ -209,7 +209,7 @@ To [revive][mdn-json-parse] a `Complex128` number from a [JSON][json] `string`, - - - - From 55f1d37a59752a47336aa7e899c911eeb494fbb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 19:15:26 +0000 Subject: [PATCH 75/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 159 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 138 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 53 files changed, 4865 insertions(+), 5832 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 55a9a71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:real', function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:imag', function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdc8bee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 8a0fa78..b36b985 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3e08077 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 7c85f4432c0ec977cecfcdcb72302bfe13949e56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 19:25:26 +0000 Subject: [PATCH 76/92] Update README.md for ESM bundle v0.1.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 25b81f1..850f36b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@esm/index.mjs'; +import Complex128 from 'https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-ctor@v0.1.2-esm/index.mjs'; ``` #### Complex128( real, imag ) @@ -209,7 +209,7 @@ To [revive][mdn-json-parse] a `Complex128` number from a [JSON][json] `string`, - - - - From 2e089ca8481f3658bb797698252f8ff5b47129f8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 20 Apr 2026 01:38:39 +0000 Subject: [PATCH 80/92] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 193 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 139 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 53 files changed, 4865 insertions(+), 5878 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d03c81f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:real', pkg ), function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:imag', pkg ), function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toJSON', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdc8bee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 1259ac4..b36b985 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3e08077 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 19b8013792fbcaedf021108eb34db088166ca9a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Apr 2026 03:20:14 +0000 Subject: [PATCH 81/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 761a6d2..3f2bf89 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index 141d880..1259ac4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.3", "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-read-only-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.4", From 04a63477bde6baf54f9ade6b4b2896106d32783a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Apr 2026 03:31:02 +0000 Subject: [PATCH 82/92] Remove files --- index.d.ts | 120 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4967 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 4a6e587..0000000 --- a/index.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Constructor name. - * - * @example - * var str = Complex128.name; - * // returns 'Complex128' - */ - static readonly name: 'Complex128'; - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdc8bee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8cca46d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3e08077..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1de857b6d8484257b3329f7580d19540f45578ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 22 Apr 2026 03:31:42 +0000 Subject: [PATCH 83/92] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 193 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 139 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 54 files changed, 4865 insertions(+), 5879 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 79746b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-22T03:18:53.801Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d03c81f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:real', pkg ), function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:imag', pkg ), function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toJSON', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdc8bee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 1259ac4..b36b985 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3e08077 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From ba60fc75186ee65b2f629873fcaefef0d86541ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 May 2026 03:28:44 +0000 Subject: [PATCH 84/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 761a6d2..3f2bf89 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index 141d880..1259ac4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.3", "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-read-only-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.4", From 78a2e8eeb2fef20e2ca6d333823578315be7b272 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 May 2026 03:39:56 +0000 Subject: [PATCH 85/92] Remove files --- index.d.ts | 120 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4967 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 4a6e587..0000000 --- a/index.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Constructor name. - * - * @example - * var str = Complex128.name; - * // returns 'Complex128' - */ - static readonly name: 'Complex128'; - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdc8bee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8cca46d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3e08077..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 09ea6123b24c0b84cca58398ccb2e7ecdbfd35eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 May 2026 03:40:33 +0000 Subject: [PATCH 86/92] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 193 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 139 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 54 files changed, 4865 insertions(+), 5897 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 94baa0f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-31T03:24:53.519Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d03c81f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:real', pkg ), function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:imag', pkg ), function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toJSON', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 09dedb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=o(function(S,n){"use strict";function c(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=c});var a=o(function(d,u){"use strict";function l(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=l});var E=o(function(q,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),y=s(),f=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",y);i(t.prototype,"toJSON",f);v.exports=t});var w=E();module.exports=w; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index e58b4ec..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdc8bee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 1259ac4..b36b985 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3e08077 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From 5fb627167142a870d429b1b264f1fa4abb6e7c12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jul 2026 03:23:45 +0000 Subject: [PATCH 87/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 761a6d2..3f2bf89 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index 141d880..1259ac4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.3", "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-read-only-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.4", From 6e468251aee25eb8d8738b0fcf639e6f4341cb37 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jul 2026 03:37:12 +0000 Subject: [PATCH 88/92] Remove files --- index.d.ts | 120 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4967 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 4a6e587..0000000 --- a/index.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Constructor name. - * - * @example - * var str = Complex128.name; - * // returns 'Complex128' - */ - static readonly name: 'Complex128'; - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdc8bee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8cca46d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3e08077..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c059ef1540bcc559ae2bb82389c19023b1e8c617 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jul 2026 03:37:29 +0000 Subject: [PATCH 89/92] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 193 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 139 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 54 files changed, 4865 insertions(+), 5897 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5008241..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-11T03:19:54.054Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d03c81f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:real', pkg ), function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:imag', pkg ), function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toJSON', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 82b7d8c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(c){throw r=0,c}}};var s=o(function(d,n){"use strict";function l(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=l});var a=o(function(q,u){"use strict";function y(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=y});var E=o(function(x,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),f=s(),w=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",f);i(t.prototype,"toJSON",w);v.exports=t});var b=E();module.exports=b; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index c0b1860..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdc8bee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 1259ac4..b36b985 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3e08077 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -}); From a1aa1cf0d61d9adf87d2d6269812f889cfb51894 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 29 Aug 2026 02:38:34 +0000 Subject: [PATCH 90/92] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 761a6d2..3f2bf89 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toStr = require( './tostring.js' ); var toJSON = require( './tojson.js' ); @@ -47,13 +47,13 @@ var toJSON = require( './tojson.js' ); */ function Complex128( real, imag ) { if ( !( this instanceof Complex128 ) ) { - throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' ); + throw new TypeError( format('null0G') ); } if ( !isNumber( real ) ) { - throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) ); + throw new TypeError( format( 'null3e', real ) ); } if ( !isNumber( imag ) ) { - throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) ); + throw new TypeError( format( 'null3f', imag ) ); } setEnumerableReadOnly( this, 're', real ); setEnumerableReadOnly( this, 'im', imag ); diff --git a/package.json b/package.json index 141d880..1259ac4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "dependencies": { "@stdlib/assert-is-number": "^0.2.3", "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-read-only-property": "^0.2.3", "@stdlib/utils-library-manifest": "^0.2.4", From 142356c8e54acbb186b5320519c54ea2a5611560 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 29 Aug 2026 03:04:21 +0000 Subject: [PATCH 91/92] Remove files --- index.d.ts | 120 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4967 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 4a6e587..0000000 --- a/index.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* 128-bit complex number. -*/ -declare class Complex128 { - /** - * 128-bit complex number constructor. - * - * @param real - real component - * @param imag - imaginary component - * @returns 128-bit complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * // returns - */ - constructor( real: number, imag: number ); - - /** - * Constructor name. - * - * @example - * var str = Complex128.name; - * // returns 'Complex128' - */ - static readonly name: 'Complex128'; - - /** - * Read-only property returning the real component. - * - * @returns real component - */ - readonly re: number; - - /** - * Read-only property returning the imaginary component. - * - * @returns imaginary component - */ - readonly im: number; - - /** - * Size (in bytes) of each component. - * - * @returns size of each component - * - * @example - * var nbytes = Complex128.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Length (in bytes) of a complex number. - * - * @returns byte length - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var nbytes = z.byteLength; - * // returns 16 - */ - readonly byteLength: 16; - - /** - * Serializes a complex number as a string. - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var str = z.toString(); - * // returns '5 + 3i' - */ - toString(): string; - - /** - * Serializes a complex number as a JSON object. - * - * ## Notes - * - * - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. - * - * - * @returns serialized complex number - * - * @example - * var z = new Complex128( 5.0, 3.0 ); - * - * var obj = z.toJSON(); - * // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } - */ - toJSON(): any; -} - - -// EXPORTS // - -export = Complex128; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdc8bee..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8cca46d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3e08077..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 18e09d1a38c99ec716707a42d1647ec4fac31a3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 29 Aug 2026 03:04:36 +0000 Subject: [PATCH 92/92] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 193 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 393 +- SECURITY.md | 5 - benchmark/benchmark.js | 139 - benchmark/julia/REQUIRE | 2 - benchmark/julia/benchmark.jl | 144 - benchmark/python/benchmark.py | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 69 - examples/c/Makefile | 146 - examples/c/example.c | 73 - examples/index.js | 38 - include/stdlib/complex/float64/ctor.h | 169 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 163 - lib/tojson.js | 39 - lib/tostring.js | 42 - manifest.json | 40 - package.json | 62 +- src/main.c | 224 - stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 224 - 54 files changed, 4865 insertions(+), 5898 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/julia/REQUIRE delete mode 100644 benchmark/julia/benchmark.jl delete mode 100644 benchmark/python/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/complex/float64/ctor.h rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 manifest.json delete mode 100644 src/main.c create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 82b7143..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-29T02:31:09.450Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 58b0c02..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index e02c9f2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/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 deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index ae67cab..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '11 23 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -248,359 +239,7 @@ console.log( 'JSON: %s', JSON.stringify( z ) ); -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/complex/float64/ctor.h" -``` - -#### stdlib_complex128_t - -An opaque type definition for a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -#### stdlib_complex128_parts_t - -An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. - -```c -double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -// ... - -// Create a complex number: -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); - -// ... - -// Access the real component: -double re = real( z ); -// returns 5.0 -``` - -The union has the following members: - -- **value**: `stdlib_complex128_t` double-precision complex floating-point number. - -- **parts**: `double[]` array having the following elements: - - - **0**: `double` real component. - - **1**: `double` imaginary component. - -#### stdlib_complex128( real, imag ) - -Returns a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. -- **imag**: `[in] double` imaginary component. - -```c -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); -``` - -#### stdlib_complex128_from_float32( real ) - -Converts a single-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -``` - -The function accepts the following arguments: - -- **real**: `[in] float` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); -``` - -#### stdlib_complex128_from_float64( real ) - -Converts a double-precision floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] double` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); -``` - -#### stdlib_complex128_from_complex64( z ) - -Converts a single-precision complex floating-point number to a double-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); -``` - -#### stdlib_complex128_from_complex128( z ) - -Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. - -```c -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); -``` - -#### stdlib_complex128_from_int8( real ) - -Converts a signed 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); -``` - -#### stdlib_complex128_from_uint8( real ) - -Converts an unsigned 8-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint8_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); -``` - -#### stdlib_complex128_from_int16( real ) - -Converts a signed 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); -``` - -#### stdlib_complex128_from_uint16( real ) - -Converts an unsigned 16-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint16_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); -``` - -#### stdlib_complex128_from_int32( real ) - -Converts a signed 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] int32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); -``` - -#### stdlib_complex128_from_uint32( real ) - -Converts an unsigned 32-bit integer to a double-precision complex floating-point number. - -```c -stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -``` - -The function accepts the following arguments: - -- **real**: `[in] uint32_t` real component. - -```c -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); -``` - -#### stdlib_complex128_to_complex64( z ) - -Converts a double-precision complex floating-point number to a single-precision complex floating-point number. - -```c -#include "stdlib/complex/float32/ctor.h" - -stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -``` - -The function accepts the following arguments: - -- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. - -```c -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} -``` - -
- - - -
- @@ -634,7 +273,7 @@ int main( void ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -703,13 +342,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse -[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver +[@stdlib/complex/float64/reviver]: https://github.com/stdlib-js/complex-float64-reviver/tree/esm -[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx +[@stdlib/complex/cmplx]: https://github.com/stdlib-js/complex-cmplx/tree/esm -[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex-float32-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d03c81f..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Complex128 = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var z; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = new Complex128( i, i ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !( z instanceof Complex128 ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:real', pkg ), function benchmark( b ) { - var re; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - re = z.re; - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( re ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:imag', pkg ), function benchmark( b ) { - var im; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: this is likely to be optimized away due to loop invariant code motion. - im = z.im; - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( im ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toString(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof o !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:toJSON', pkg ), function benchmark( b ) { - var o; - var z; - var i; - - z = new Complex128( randu(), randu() ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = z.toJSON(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/julia/REQUIRE b/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e1..0000000 --- a/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/benchmark/julia/benchmark.jl b/benchmark/julia/benchmark.jl deleted file mode 100644 index e2d019c..0000000 --- a/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env julia -# -# @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. - -import BenchmarkTools -using Printf - -# Benchmark variables: -name = "complex128"; -repeats = 3; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, passing ) - @printf( "#\n" ); - @printf( "1..%d\n", total ); # TAP plan - @printf( "# total %d\n", total ); - @printf( "# pass %d\n", passing ); - @printf( "#\n" ); - @printf( "# ok\n" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark() - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Examples - -``` julia -julia> out = benchmark(); -``` -""" -function benchmark() - t = BenchmarkTools.@benchmark ComplexF64( rand(), rand() ) samples=1e6 - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - for i in 1:repeats - @printf( "# julia::%s\n", name ); - results = benchmark(); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", i ); - end - print_summary( repeats, repeats ); -end - -main(); diff --git a/benchmark/python/benchmark.py b/benchmark/python/benchmark.py deleted file mode 100644 index 16e15dd..0000000 --- a/benchmark/python/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark complex.""" - -from __future__ import print_function -import timeit - -NAME = "complex128" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "from random import random;" - stmt = "z = complex(random(), random())" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3570b61..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor" -%% click B href "https://github.com/stdlib-js/complex-float64-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/complex-float64-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/complex-float64-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/complex-float64-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/complex-float64-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor -[production-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/complex-float64-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/complex-float64-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 733f272..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Complex128 from '../docs/types/index'; -export = Complex128; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 82b7d8c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var o=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(c){throw r=0,c}}};var s=o(function(d,n){"use strict";function l(){var e=""+this.re;return this.im<0?e+=" - "+-this.im:e+=" + "+this.im,e+="i",e}n.exports=l});var a=o(function(q,u){"use strict";function y(){var e={};return e.type="Complex128",e.re=this.re,e.im=this.im,e}u.exports=y});var E=o(function(x,v){"use strict";var m=require("@stdlib/assert-is-number").isPrimitive,p=require("@stdlib/utils-define-read-only-property"),i=require("@stdlib/utils-define-nonenumerable-read-only-property"),h=require("@stdlib/string-format"),f=s(),w=a();function t(e,r){if(!(this instanceof t))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!m(e))throw new TypeError(h("invalid argument. Real component must be a number. Value: `%s`.",e));if(!m(r))throw new TypeError(h("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return p(this,"re",e),p(this,"im",r),this}i(t,"name","Complex128");i(t,"BYTES_PER_ELEMENT",8);i(t.prototype,"BYTES_PER_ELEMENT",8);i(t.prototype,"byteLength",16);i(t.prototype,"toString",f);i(t.prototype,"toJSON",w);v.exports=t});var b=E();module.exports=b; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index c0b1860..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar format = require( '@stdlib/string-format' );\nvar toStr = require( './tostring.js' );\nvar toJSON = require( './tojson.js' );\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nmodule.exports = Complex128;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 128-bit complex number constructor.\n*\n* @module @stdlib/complex-float64-ctor\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAW,CAEnB,IAAIC,EAAM,GAAK,KAAK,GACpB,OAAK,KAAK,GAAK,EACdA,GAAO,MAAS,CAAC,KAAK,GAEtBA,GAAO,MAAQ,KAAK,GAErBA,GAAO,IACAA,CACR,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,GAAS,CAEjB,IAAIC,EAAM,CAAC,EACX,OAAAA,EAAI,KAAO,aACXA,EAAI,GAAK,KAAK,GACdA,EAAI,GAAK,KAAK,GACPA,CACR,CAKAF,EAAO,QAAUC,ICtCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAwB,QAAS,yCAA0C,EAC3EC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,uBAAwB,EAC1CC,EAAQ,IACRC,EAAS,IAoBb,SAASC,EAAYC,EAAMC,EAAO,CACjC,GAAK,EAAG,gBAAgBF,GACvB,MAAM,IAAI,UAAW,wEAAyE,EAE/F,GAAK,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWJ,EAAQ,kEAAmEI,CAAK,CAAE,EAExG,GAAK,CAACP,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,EAE7G,OAAAP,EAAuB,KAAM,KAAMM,CAAK,EACxCN,EAAuB,KAAM,KAAMO,CAAK,EACjC,IACR,CAeAN,EAAaI,EAAY,OAAQ,YAAa,EAc9CJ,EAAaI,EAAY,oBAAqB,CAAE,EAgBhDJ,EAAaI,EAAW,UAAW,oBAAqB,CAAE,EAgB1DJ,EAAaI,EAAW,UAAW,aAAc,EAAG,EAgBpDJ,EAAaI,EAAW,UAAW,WAAYF,CAAM,EAoBrDF,EAAaI,EAAW,UAAW,SAAUD,CAAO,EAKpDN,EAAO,QAAUO,IChIjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_tostring", "__commonJSMin", "exports", "module", "toString", "str", "require_tojson", "__commonJSMin", "exports", "module", "toJSON", "out", "require_main", "__commonJSMin", "exports", "module", "isNumber", "setEnumerableReadOnly", "setReadOnly", "format", "toStr", "toJSON", "Complex128", "real", "imag", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0788a5c..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( real, imag ) - 128-bit complex number constructor. - - Both the real and imaginary components are stored as double-precision - floating-point numbers. - - Parameters - ---------- - real: number - Real component. - - imag: number - Imaginary component. - - Returns - ------- - z: Complex128 - 128-bit complex number. - - z.re: number - Read-only property returning the real component. - - z.im: number - Read-only property returning the imaginary component. - - -{{alias}}.name - Constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128' - - -{{alias}}.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - v: integer - Size (in bytes) of each component. - - Examples - -------- - > var s = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each component. - - Returns - ------- - s: integer - Size (in bytes) of each component. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.byteLength - Length (in bytes) of a complex number. - - Returns - ------- - len: integer - Length (in bytes) of a complex number. - - Examples - -------- - > var z = new {{alias}}( 5.0, 3.0 ) - - > var s = z.byteLength - 16 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 98f2e8b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( './index' ); - - -// TESTS // - -// The function returns a 128-bit complex number with the expected properties... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.im; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.re; // $ExpectType number - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.BYTES_PER_ELEMENT; // $ExpectType 8 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.byteLength; // $ExpectType 16 -} - -// 128-bit complex number comes with a `toString` method to serialize a complex number as a string... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toString(); // $ExpectType string -} - -// 128-bit complex number comes with a `toJSON` method to serialize a complex number as a JSON object... -{ - const x = new Complex128( 5.0, 3.0 ); // $ExpectType Complex128 - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - x.toJSON(); // $ExpectType any -} - -// The compiler throws an error if the constructor is invoked without the `new` keyword... -{ - Complex128( 5.0, 3.0 ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0 ); // $ExpectError - - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - new Complex128( 5.0, 3.0, 1.0 ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 70c91f4..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index d9f5b3d..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include -#include - -/** -* Return the real component of a double-precision complex floating-point number. -* -* @param z complex number -* @return real component -*/ -static double real( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the real component: - double re = v.parts[ 0 ]; - - return re; -} - -/** -* Return the imaginary component of a double-precision complex floating-point number. -* -* @param z complex number -* @return imaginary component -*/ -static double imag( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v; - - // Assign a double-precision complex floating-point number: - v.value = z; // cppcheck-suppress unreadVariable - - // Extract the imaginary component: - double im = v.parts[ 1 ]; - - return im; -} - -int main( void ) { - const stdlib_complex128_t x[] = { - stdlib_complex128( 5.0, 2.0 ), - stdlib_complex128( -2.0, 1.0 ), - stdlib_complex128( 0.0, -0.0 ), - stdlib_complex128( 0.0/0.0, 0.0/0.0 ) - }; - - stdlib_complex128_t v; - int i; - for ( i = 0; i < 4; i++ ) { - v = x[ i ]; - printf( "%lf + %lfi\n", real( v ), imag( v ) ); - } -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d41d707..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( './../lib' ); - -var z = new Complex128( 3.0, -2.0 ); - -console.log( 'type: %s', typeof z ); -// => 'type: object' - -console.log( 'str: %s', z ); -// => 'str: 3 - 2i' - -console.log( 'real: %d', z.re ); -// => 'real: 3' - -console.log( 'imaginary: %d', z.im ); -// => 'imaginary: -2' - -console.log( 'JSON: %s', JSON.stringify( z ) ); -// => 'JSON: {"type":"Complex128","re":3,"im":-2}' diff --git a/include/stdlib/complex/float64/ctor.h b/include/stdlib/complex/float64/ctor.h deleted file mode 100644 index f23acfc..0000000 --- a/include/stdlib/complex/float64/ctor.h +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_COMPLEX_FLOAT64_CTOR_H -#define STDLIB_COMPLEX_FLOAT64_CTOR_H - -#include "stdlib/complex/float32/ctor.h" -#include -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -// Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality) -#if defined(_Imaginary_I) && defined(CMPLX) - -/** -* An opaque type definition for a double-precision complex floating-point number. -*/ -typedef double complex stdlib_complex128_t; - -// If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components... -#else - -/** -* An opaque type definition for a double-precision complex floating-point number. -* -* @example -* stdlib_complex128_t z; -* -* // Set the real component: -* z.re = 5.0; -* -* // Set the imaginary component: -* z.im = 2.0; -*/ -typedef struct { - /** - * Real component. - */ - double re; - - /** - * Imaginary component. - */ - double im; -} stdlib_complex128_t; - -#endif - -/** -* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. -* -* @example -* double real( const stdlib_complex128_t z ) { -* stdlib_complex128_parts_t v; -* -* // Assign a double-precision complex floating-point number: -* v.value = z; -* -* // Extract the real component: -* double re = v.parts[ 0 ]; -* -* return re; -* } -* -* // ... -* -* // Create a complex number: -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -* -* // ... -* -* // Access the real component: -* double re = real( z ); -* // returns 5.0 -*/ -typedef union { - // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number): - stdlib_complex128_t value; - - // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see ), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`): - double parts[ 2 ]; -} stdlib_complex128_parts_t; - -/** -* Returns a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ); - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ); - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ); - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_COMPLEX_FLOAT64_CTOR_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bdc8bee --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-only-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(r,n){if(!(this instanceof s))throw new TypeError(i("null0G"));if(!t(r))throw new TypeError(i("null3e",r));if(!t(n))throw new TypeError(i("null3f",n));return e(this,"re",r),e(this,"im",n),this}r(s,"name","Complex128"),r(s,"BYTES_PER_ELEMENT",8),r(s.prototype,"BYTES_PER_ELEMENT",8),r(s.prototype,"byteLength",16),r(s.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),r(s.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8cca46d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/tostring.js","../lib/tojson.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport setEnumerableReadOnly from '@stdlib/utils-define-read-only-property';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( format('null0G') );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'null3e', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'null3f', imag ) );\n\t}\n\tsetEnumerableReadOnly( this, 're', real );\n\tsetEnumerableReadOnly( this, 'im', imag );\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128\n* @readonly\n* @type {string}\n* @default 'Complex128'\n*\n* @example\n* var name = Complex128.name;\n* // returns 'Complex128'\n*/\nsetReadOnly( Complex128, 'name', 'Complex128' );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["Complex128","real","imag","this","TypeError","format","isNumber","setEnumerableReadOnly","setReadOnly","prototype","str","re","im","out"],"mappings":";;6aA+CA,SAASA,EAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,GACvB,MAAM,IAAII,UAAWC,EAAO,WAE7B,IAAMC,EAAUL,GACf,MAAM,IAAIG,UAAWC,EAAQ,SAAUJ,IAExC,IAAMK,EAAUJ,GACf,MAAM,IAAIE,UAAWC,EAAQ,SAAUH,IAIxC,OAFAK,EAAuBJ,KAAM,KAAMF,GACnCM,EAAuBJ,KAAM,KAAMD,GAC5BC,IACR,CAeAK,EAAaR,EAAY,OAAQ,cAcjCQ,EAAaR,EAAY,oBAAqB,GAgB9CQ,EAAaR,EAAWS,UAAW,oBAAqB,GAgBxDD,EAAaR,EAAWS,UAAW,aAAc,IAgBjDD,EAAaR,EAAWS,UAAW,YC/GnC,WAEC,IAAIC,EAAM,GAAKP,KAAKQ,GAOpB,OANKR,KAAKS,GAAK,EACdF,GAAO,OAAUP,KAAKS,GAEtBF,GAAO,MAAQP,KAAKS,GAErBF,GAAO,GAER,IDyHAF,EAAaR,EAAWS,UAAW,UEnInC,WAEC,IAAII,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIF,GAAKR,KAAKQ,GACdE,EAAID,GAAKT,KAAKS,GACPC,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index c6a6ece..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number constructor. -* -* @module @stdlib/complex-float64-ctor -* -* @example -* var Complex128 = require( '@stdlib/complex-float64-ctor' ); -* -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3f2bf89..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var setEnumerableReadOnly = require( '@stdlib/utils-define-read-only-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toStr = require( './tostring.js' ); -var toJSON = require( './tojson.js' ); - - -// MAIN // - -/** -* 128-bit complex number constructor. -* -* @constructor -* @param {number} real - real component -* @param {number} imag - imaginary component -* @throws {TypeError} must invoke using the `new` keyword -* @throws {TypeError} real component must be a number -* @throws {TypeError} imaginary component must be a number -* @returns {Complex128} 128-bit complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* // returns -*/ -function Complex128( real, imag ) { - if ( !( this instanceof Complex128 ) ) { - throw new TypeError( format('null0G') ); - } - if ( !isNumber( real ) ) { - throw new TypeError( format( 'null3e', real ) ); - } - if ( !isNumber( imag ) ) { - throw new TypeError( format( 'null3f', imag ) ); - } - setEnumerableReadOnly( this, 're', real ); - setEnumerableReadOnly( this, 'im', imag ); - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof Complex128 -* @readonly -* @type {string} -* @default 'Complex128' -* -* @example -* var name = Complex128.name; -* // returns 'Complex128' -*/ -setReadOnly( Complex128, 'name', 'Complex128' ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128 -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var nbytes = Complex128.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Size (in bytes) of each component. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} size of each component -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 ); - -/** -* Length (in bytes) of a complex number. -* -* @name byteLength -* @memberof Complex128.prototype -* @type {integer} -* @returns {integer} byte length -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var nbytes = z.byteLength; -* // returns 16 -*/ -setReadOnly( Complex128.prototype, 'byteLength', 16 ); - -/** -* Serializes a complex number as a string. -* -* @name toString -* @memberof Complex128.prototype -* @type {Function} -* @returns {string} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var str = z.toString(); -* // returns '5 + 3i' -*/ -setReadOnly( Complex128.prototype, 'toString', toStr ); - -/** -* Serializes a complex number as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance. -* -* @name toJSON -* @memberof Complex128.prototype -* @type {Function} -* @returns {Object} serialized complex number -* -* @example -* var z = new Complex128( 5.0, 3.0 ); -* -* var obj = z.toJSON(); -* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 } -*/ -setReadOnly( Complex128.prototype, 'toJSON', toJSON ); - - -// EXPORTS // - -module.exports = Complex128; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 407760e..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a JSON object. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out = {}; - out.type = 'Complex128'; - out.re = this.re; - out.im = this.im; - return out; -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index d57bdc1..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Serializes a complex number as a string. -* -* @private -* @returns {string} serialized complex number -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var str = '' + this.re; - if ( this.im < 0 ) { - str += ' - ' + (-this.im); - } else { - str += ' + ' + this.im; - } - str += 'i'; - return str; -} - - -// EXPORTS // - -module.exports = toString; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 465cb4b..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/complex-float32-ctor" - ] - } - ] -} diff --git a/package.json b/package.json index 1259ac4..b36b985 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.2", "description": "128-bit complex number.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "include": "./include", - "lib": "./lib", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/complex-float32-ctor": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-only-property": "^0.2.3", - "@stdlib/utils-library-manifest": "^0.2.4", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/src/main.c b/src/main.c deleted file mode 100644 index cbd0d95..0000000 --- a/src/main.c +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/complex/float64/ctor.h" -#include "stdlib/complex/float32/ctor.h" -#include - -/** -* Returns a double-precision complex floating-point number. -* -* @param real real component -* @param imag imaginary component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); -*/ -stdlib_complex128_t stdlib_complex128( const double real, const double imag ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); -*/ -stdlib_complex128_t stdlib_complex128_from_float32( const float real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision floating-point number to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); -*/ -stdlib_complex128_t stdlib_complex128_from_float64( const double real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a single-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z single-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) { - stdlib_complex64_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = (double)v1.parts[ 0 ]; - v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); -*/ -stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex128_parts_t v2; - v2.parts[ 0 ] = v1.parts[ 0 ]; - v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} - -/** -* Converts a signed 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 8-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 16-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a signed 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts an unsigned 32-bit integer to a double-precision complex floating-point number. -* -* @param real real component -* @return double-precision complex floating-point number -* -* @example -* stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); -*/ -stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) { - stdlib_complex128_parts_t z; - z.parts[ 0 ] = (double)real; - z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable - return z.value; -} - -/** -* Converts a double-precision complex floating-point number to a single-precision complex floating-point number. -* -* @param z double-precision complex floating-point number -* @return single-precision complex floating-point number -* -* @example -* #include "stdlib/complex/float32/ctor.h" -* -* stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); -* stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); -*/ -stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) { - stdlib_complex128_parts_t v1 = { z }; - stdlib_complex64_parts_t v2; - v2.parts[ 0 ] = (float)v1.parts[ 0 ]; - v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable - return v2.value; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3e08077 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d011874..0000000 --- a/test/test.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Complex128 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z instanceof Complex128, true, 'is an instance' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a real component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( value, 3.0 ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor throws an error if provided an imaginary component which is not a number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - void 0, - true, - false, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var z = new Complex128( 5.0, value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the constructor requires the `new` keyword', function test( t ) { - var ctor = Complex128; - t.throws( foo, TypeError, 'throws an error' ); - t.end(); - - function foo() { - ctor( 5.0, 3.0 ); - } -}); - -tape( 'the constructor has a read-only `name` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'name' ), true, 'has property' ); - t.strictEqual( Complex128.name, 'Complex128', 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.name = 'Foo'; - } -}); - -tape( 'the constructor has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `BYTES_PER_ELEMENT` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.BYTES_PER_ELEMENT = 16; - } -}); - -tape( 'the constructor prototype has a read-only `byteLength` property', function test( t ) { - t.strictEqual( hasOwnProp( Complex128.prototype, 'byteLength' ), true, 'has property' ); - t.strictEqual( Complex128.prototype.byteLength, 16, 'returns expected value' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - Complex128.prototype.byteLength = 64; - } -}); - -tape( 'the constructor returns an instance having a property for getting the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.re, 5.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the real component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.re = -5.0; - } -}); - -tape( 'the constructor returns an instance having a property for getting the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.im, 3.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance which throws an error when attempting to mutate the imaginary component', function test( t ) { - var z = new Complex128( 5.0, 3.0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - z.im = -3.0; - } -}); - -tape( 'the constructor returns an instance which stores real and imaginary components as double-precision floating-point numbers', function test( t ) { - var z = new Complex128( 3.14, -3.14 ); - - t.strictEqual( z.re, 3.14, 'stores as double-precision' ); - t.strictEqual( z.im, -3.14, 'stores as double-precision' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a string', function test( t ) { - var z; - - z = new Complex128( 5.0, -3.0 ); - t.strictEqual( z.toString(), '5 - 3i', 'returns expected value' ); - - z = new Complex128( 5.0, 3.0 ); - t.strictEqual( z.toString(), '5 + 3i', 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance which supports serializing an instance as a JSON object', function test( t ) { - var expected; - var z; - - z = new Complex128( 5.0, -3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': -3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - z = new Complex128( 5.0, 3.0 ); - expected = { - 'type': 'Complex128', - 're': 5.0, - 'im': 3.0 - }; - t.deepEqual( z.toJSON(), expected, 'returns expected value' ); - t.strictEqual( JSON.stringify( z ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); - - t.end(); -});