@ohos-ports/stdlib-complex-real 0.0.0-stage → 0.2.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +320 -2
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +44 -0
- package/include/stdlib/complex/real.h +40 -0
- package/lib/index.js +43 -0
- package/lib/main.js +42 -0
- package/manifest.json +40 -0
- package/node_modules/@stdlib/array-float32/LICENSE +177 -0
- package/node_modules/@stdlib/array-float32/NOTICE +1 -0
- package/node_modules/@stdlib/array-float32/README.md +1577 -0
- package/node_modules/@stdlib/array-float32/SECURITY.md +5 -0
- package/node_modules/@stdlib/array-float32/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/array-float32/dist/index.js +19 -0
- package/node_modules/@stdlib/array-float32/dist/index.js.map +7 -0
- package/node_modules/@stdlib/array-float32/docs/types/index.d.ts +26 -0
- package/node_modules/@stdlib/array-float32/lib/index.js +52 -0
- package/node_modules/@stdlib/array-float32/lib/main.js +28 -0
- package/node_modules/@stdlib/array-float32/lib/polyfill.js +37 -0
- package/node_modules/@stdlib/array-float32/package.json +72 -0
- package/node_modules/@stdlib/assert-has-float32array-support/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-float32array-support/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-float32array-support/README.md +187 -0
- package/node_modules/@stdlib/assert-has-float32array-support/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-float32array-support/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-float32array-support/dist/index.js +7 -0
- package/node_modules/@stdlib/assert-has-float32array-support/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-float32array-support/docs/types/index.d.ts +35 -0
- package/node_modules/@stdlib/assert-has-float32array-support/lib/float32array.js +28 -0
- package/node_modules/@stdlib/assert-has-float32array-support/lib/index.js +40 -0
- package/node_modules/@stdlib/assert-has-float32array-support/lib/main.js +65 -0
- package/node_modules/@stdlib/assert-has-float32array-support/package.json +77 -0
- package/node_modules/@stdlib/assert-has-own-property/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-own-property/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-own-property/README.md +263 -0
- package/node_modules/@stdlib/assert-has-own-property/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-own-property/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-own-property/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-has-own-property/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-own-property/docs/types/index.d.ts +49 -0
- package/node_modules/@stdlib/assert-has-own-property/lib/index.js +47 -0
- package/node_modules/@stdlib/assert-has-own-property/lib/main.js +64 -0
- package/node_modules/@stdlib/assert-has-own-property/package.json +73 -0
- package/node_modules/@stdlib/assert-has-symbol-support/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-symbol-support/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-symbol-support/README.md +193 -0
- package/node_modules/@stdlib/assert-has-symbol-support/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-symbol-support/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-symbol-support/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-has-symbol-support/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-symbol-support/docs/types/index.d.ts +35 -0
- package/node_modules/@stdlib/assert-has-symbol-support/lib/index.js +40 -0
- package/node_modules/@stdlib/assert-has-symbol-support/lib/main.js +42 -0
- package/node_modules/@stdlib/assert-has-symbol-support/package.json +72 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/LICENSE +177 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/NOTICE +1 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/README.md +187 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/docs/types/index.d.ts +35 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/lib/index.js +40 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/lib/main.js +49 -0
- package/node_modules/@stdlib/assert-has-tostringtag-support/package.json +78 -0
- package/node_modules/@stdlib/assert-is-float32array/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-float32array/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-float32array/README.md +229 -0
- package/node_modules/@stdlib/assert-is-float32array/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-float32array/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-float32array/dist/index.js +5 -0
- package/node_modules/@stdlib/assert-is-float32array/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-float32array/docs/types/index.d.ts +42 -0
- package/node_modules/@stdlib/assert-is-float32array/lib/index.js +44 -0
- package/node_modules/@stdlib/assert-is-float32array/lib/main.js +59 -0
- package/node_modules/@stdlib/assert-is-float32array/package.json +81 -0
- package/node_modules/@stdlib/assert-is-number/LICENSE +177 -0
- package/node_modules/@stdlib/assert-is-number/NOTICE +1 -0
- package/node_modules/@stdlib/assert-is-number/README.md +231 -0
- package/node_modules/@stdlib/assert-is-number/SECURITY.md +5 -0
- package/node_modules/@stdlib/assert-is-number/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/assert-is-number/dist/index.js +13 -0
- package/node_modules/@stdlib/assert-is-number/dist/index.js.map +7 -0
- package/node_modules/@stdlib/assert-is-number/docs/types/index.d.ts +121 -0
- package/node_modules/@stdlib/assert-is-number/lib/index.js +79 -0
- package/node_modules/@stdlib/assert-is-number/lib/main.js +58 -0
- package/node_modules/@stdlib/assert-is-number/lib/object.js +66 -0
- package/node_modules/@stdlib/assert-is-number/lib/primitive.js +46 -0
- package/node_modules/@stdlib/assert-is-number/lib/tostring.js +34 -0
- package/node_modules/@stdlib/assert-is-number/lib/try2serialize.js +47 -0
- package/node_modules/@stdlib/assert-is-number/package.json +80 -0
- package/node_modules/@stdlib/complex-float32/LICENSE +177 -0
- package/node_modules/@stdlib/complex-float32/NOTICE +1 -0
- package/node_modules/@stdlib/complex-float32/README.md +629 -0
- package/node_modules/@stdlib/complex-float32/SECURITY.md +5 -0
- package/node_modules/@stdlib/complex-float32/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/complex-float32/dist/index.js +9 -0
- package/node_modules/@stdlib/complex-float32/dist/index.js.map +7 -0
- package/node_modules/@stdlib/complex-float32/docs/types/index.d.ts +111 -0
- package/node_modules/@stdlib/complex-float32/include/stdlib/complex/float32.h +148 -0
- package/node_modules/@stdlib/complex-float32/lib/index.js +40 -0
- package/node_modules/@stdlib/complex-float32/lib/main.js +159 -0
- package/node_modules/@stdlib/complex-float32/lib/tojson.js +39 -0
- package/node_modules/@stdlib/complex-float32/lib/tostring.js +42 -0
- package/node_modules/@stdlib/complex-float32/manifest.json +38 -0
- package/node_modules/@stdlib/complex-float32/package.json +76 -0
- package/node_modules/@stdlib/complex-float32/src/main.c +151 -0
- package/node_modules/@stdlib/complex-float64/LICENSE +177 -0
- package/node_modules/@stdlib/complex-float64/NOTICE +1 -0
- package/node_modules/@stdlib/complex-float64/README.md +699 -0
- package/node_modules/@stdlib/complex-float64/SECURITY.md +5 -0
- package/node_modules/@stdlib/complex-float64/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/complex-float64/dist/index.js +9 -0
- package/node_modules/@stdlib/complex-float64/dist/index.js.map +7 -0
- package/node_modules/@stdlib/complex-float64/docs/types/index.d.ts +111 -0
- package/node_modules/@stdlib/complex-float64/include/stdlib/complex/float64.h +169 -0
- package/node_modules/@stdlib/complex-float64/lib/index.js +40 -0
- package/node_modules/@stdlib/complex-float64/lib/main.js +158 -0
- package/node_modules/@stdlib/complex-float64/lib/tojson.js +39 -0
- package/node_modules/@stdlib/complex-float64/lib/tostring.js +42 -0
- package/node_modules/@stdlib/complex-float64/manifest.json +40 -0
- package/node_modules/@stdlib/complex-float64/package.json +75 -0
- package/node_modules/@stdlib/complex-float64/src/main.c +224 -0
- package/node_modules/@stdlib/constants-float64-pinf/LICENSE +177 -0
- package/node_modules/@stdlib/constants-float64-pinf/NOTICE +1 -0
- package/node_modules/@stdlib/constants-float64-pinf/README.md +238 -0
- package/node_modules/@stdlib/constants-float64-pinf/SECURITY.md +5 -0
- package/node_modules/@stdlib/constants-float64-pinf/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/constants-float64-pinf/dist/index.js +3 -0
- package/node_modules/@stdlib/constants-float64-pinf/dist/index.js.map +7 -0
- package/node_modules/@stdlib/constants-float64-pinf/docs/types/index.d.ts +33 -0
- package/node_modules/@stdlib/constants-float64-pinf/include/stdlib/constants/float64/pinf.h +29 -0
- package/node_modules/@stdlib/constants-float64-pinf/lib/index.js +56 -0
- package/node_modules/@stdlib/constants-float64-pinf/manifest.json +36 -0
- package/node_modules/@stdlib/constants-float64-pinf/package.json +71 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/LICENSE +177 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/NOTICE +1 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/README.md +182 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/SECURITY.md +5 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/dist/index.js +5 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/dist/index.js.map +7 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/docs/types/index.d.ts +39 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/lib/index.js +40 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/lib/main.js +48 -0
- package/node_modules/@stdlib/error-tools-fmtprodmsg/package.json +70 -0
- package/node_modules/@stdlib/number-ctor/LICENSE +177 -0
- package/node_modules/@stdlib/number-ctor/NOTICE +1 -0
- package/node_modules/@stdlib/number-ctor/README.md +212 -0
- package/node_modules/@stdlib/number-ctor/SECURITY.md +5 -0
- package/node_modules/@stdlib/number-ctor/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/number-ctor/dist/index.js +5 -0
- package/node_modules/@stdlib/number-ctor/dist/index.js.map +7 -0
- package/node_modules/@stdlib/number-ctor/docs/types/index.d.ts +30 -0
- package/node_modules/@stdlib/number-ctor/lib/index.js +40 -0
- package/node_modules/@stdlib/number-ctor/lib/main.js +23 -0
- package/node_modules/@stdlib/number-ctor/package.json +62 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/LICENSE +177 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/NOTICE +1 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/README.md +191 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/SECURITY.md +5 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/dist/index.js +19 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/dist/index.js.map +7 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/docs/types/index.d.ts +36 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/lib/index.js +51 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/lib/main.js +28 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/lib/polyfill.js +51 -0
- package/node_modules/@stdlib/number-float64-base-to-float32/package.json +76 -0
- package/node_modules/@stdlib/string-base-format-interpolate/LICENSE +177 -0
- package/node_modules/@stdlib/string-base-format-interpolate/NOTICE +1 -0
- package/node_modules/@stdlib/string-base-format-interpolate/README.md +219 -0
- package/node_modules/@stdlib/string-base-format-interpolate/SECURITY.md +5 -0
- package/node_modules/@stdlib/string-base-format-interpolate/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/string-base-format-interpolate/dist/index.js +17 -0
- package/node_modules/@stdlib/string-base-format-interpolate/dist/index.js.map +7 -0
- package/node_modules/@stdlib/string-base-format-interpolate/docs/types/index.d.ts +71 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/format_double.js +103 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/format_integer.js +115 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/index.js +41 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/is_number.js +46 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/is_string.js +42 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/main.js +243 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/space_pad.js +65 -0
- package/node_modules/@stdlib/string-base-format-interpolate/lib/zero_pad.js +84 -0
- package/node_modules/@stdlib/string-base-format-interpolate/package.json +71 -0
- package/node_modules/@stdlib/string-base-format-tokenize/LICENSE +177 -0
- package/node_modules/@stdlib/string-base-format-tokenize/NOTICE +1 -0
- package/node_modules/@stdlib/string-base-format-tokenize/README.md +203 -0
- package/node_modules/@stdlib/string-base-format-tokenize/SECURITY.md +5 -0
- package/node_modules/@stdlib/string-base-format-tokenize/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/string-base-format-tokenize/dist/index.js +5 -0
- package/node_modules/@stdlib/string-base-format-tokenize/dist/index.js.map +7 -0
- package/node_modules/@stdlib/string-base-format-tokenize/docs/types/index.d.ts +68 -0
- package/node_modules/@stdlib/string-base-format-tokenize/lib/index.js +41 -0
- package/node_modules/@stdlib/string-base-format-tokenize/lib/main.js +95 -0
- package/node_modules/@stdlib/string-base-format-tokenize/package.json +69 -0
- package/node_modules/@stdlib/string-format/LICENSE +177 -0
- package/node_modules/@stdlib/string-format/NOTICE +1 -0
- package/node_modules/@stdlib/string-format/README.md +341 -0
- package/node_modules/@stdlib/string-format/SECURITY.md +5 -0
- package/node_modules/@stdlib/string-format/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/string-format/dist/index.js +7 -0
- package/node_modules/@stdlib/string-format/dist/index.js.map +7 -0
- package/node_modules/@stdlib/string-format/docs/types/index.d.ts +42 -0
- package/node_modules/@stdlib/string-format/lib/index.js +43 -0
- package/node_modules/@stdlib/string-format/lib/is_string.js +42 -0
- package/node_modules/@stdlib/string-format/lib/main.js +64 -0
- package/node_modules/@stdlib/string-format/package.json +72 -0
- package/node_modules/@stdlib/symbol-ctor/LICENSE +177 -0
- package/node_modules/@stdlib/symbol-ctor/NOTICE +1 -0
- package/node_modules/@stdlib/symbol-ctor/README.md +234 -0
- package/node_modules/@stdlib/symbol-ctor/SECURITY.md +5 -0
- package/node_modules/@stdlib/symbol-ctor/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/symbol-ctor/dist/index.js +5 -0
- package/node_modules/@stdlib/symbol-ctor/dist/index.js.map +7 -0
- package/node_modules/@stdlib/symbol-ctor/docs/types/index.d.ts +34 -0
- package/node_modules/@stdlib/symbol-ctor/lib/index.js +40 -0
- package/node_modules/@stdlib/symbol-ctor/lib/main.js +28 -0
- package/node_modules/@stdlib/symbol-ctor/package.json +62 -0
- package/node_modules/@stdlib/types/LICENSE +177 -0
- package/node_modules/@stdlib/types/NOTICE +1 -0
- package/node_modules/@stdlib/types/README.md +212 -0
- package/node_modules/@stdlib/types/SECURITY.md +5 -0
- package/node_modules/@stdlib/types/index.d.ts +3923 -0
- package/node_modules/@stdlib/types/lib/browser.js +28 -0
- package/node_modules/@stdlib/types/lib/index.js +39 -0
- package/node_modules/@stdlib/types/lib/main.js +40 -0
- package/node_modules/@stdlib/types/package.json +67 -0
- package/node_modules/@stdlib/types/test.ts +734 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/LICENSE +177 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/NOTICE +1 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/README.md +216 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/index.js +31 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/dist/main.js +58 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/docs/types/index.d.ts +52 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/lib/index.js +47 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/lib/main.js +58 -0
- package/node_modules/@stdlib/utils-define-nonenumerable-read-only-property/package.json +92 -0
- package/node_modules/@stdlib/utils-define-property/LICENSE +177 -0
- package/node_modules/@stdlib/utils-define-property/NOTICE +1 -0
- package/node_modules/@stdlib/utils-define-property/README.md +228 -0
- package/node_modules/@stdlib/utils-define-property/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-define-property/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-define-property/dist/index.js +36 -0
- package/node_modules/@stdlib/utils-define-property/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-define-property/docs/types/index.d.ts +52 -0
- package/node_modules/@stdlib/utils-define-property/lib/builtin.js +61 -0
- package/node_modules/@stdlib/utils-define-property/lib/define_property.js +28 -0
- package/node_modules/@stdlib/utils-define-property/lib/has_define_property_support.js +51 -0
- package/node_modules/@stdlib/utils-define-property/lib/index.js +58 -0
- package/node_modules/@stdlib/utils-define-property/lib/polyfill.js +122 -0
- package/node_modules/@stdlib/utils-define-property/package.json +74 -0
- package/node_modules/@stdlib/utils-native-class/LICENSE +177 -0
- package/node_modules/@stdlib/utils-native-class/NOTICE +1 -0
- package/node_modules/@stdlib/utils-native-class/README.md +349 -0
- package/node_modules/@stdlib/utils-native-class/SECURITY.md +5 -0
- package/node_modules/@stdlib/utils-native-class/dist/index.d.ts +3 -0
- package/node_modules/@stdlib/utils-native-class/dist/index.js +11 -0
- package/node_modules/@stdlib/utils-native-class/dist/index.js.map +7 -0
- package/node_modules/@stdlib/utils-native-class/docs/types/index.d.ts +51 -0
- package/node_modules/@stdlib/utils-native-class/lib/index.js +61 -0
- package/node_modules/@stdlib/utils-native-class/lib/main.js +56 -0
- package/node_modules/@stdlib/utils-native-class/lib/polyfill.js +81 -0
- package/node_modules/@stdlib/utils-native-class/lib/tostring.js +28 -0
- package/node_modules/@stdlib/utils-native-class/lib/tostringtag.js +33 -0
- package/node_modules/@stdlib/utils-native-class/package.json +83 -0
- package/package.json +72 -4
- package/src/main.c +42 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/tostring.js", "../lib/tojson.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"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 <Complex128>\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\n*\n* @example\n* var Complex128 = require( '@stdlib/complex-float64' );\n*\n* var z = new Complex128( 5.0, 3.0 );\n* // returns <Complex128>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"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",
|
|
6
|
+
"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"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2021 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 128-bit complex number.
|
|
23
|
+
*/
|
|
24
|
+
declare class Complex128 {
|
|
25
|
+
/**
|
|
26
|
+
* 128-bit complex number constructor.
|
|
27
|
+
*
|
|
28
|
+
* @param real - real component
|
|
29
|
+
* @param imag - imaginary component
|
|
30
|
+
* @returns 128-bit complex number
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
34
|
+
* // returns <Complex128>
|
|
35
|
+
*/
|
|
36
|
+
constructor( real: number, imag: number );
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Read-only property returning the real component.
|
|
40
|
+
*
|
|
41
|
+
* @returns real component
|
|
42
|
+
*/
|
|
43
|
+
readonly re: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Read-only property returning the imaginary component.
|
|
47
|
+
*
|
|
48
|
+
* @returns imaginary component
|
|
49
|
+
*/
|
|
50
|
+
readonly im: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Size (in bytes) of each component.
|
|
54
|
+
*
|
|
55
|
+
* @returns size of each component
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var nbytes = Complex128.BYTES_PER_ELEMENT;
|
|
59
|
+
* // returns 8
|
|
60
|
+
*/
|
|
61
|
+
readonly BYTES_PER_ELEMENT: 8;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Length (in bytes) of a complex number.
|
|
65
|
+
*
|
|
66
|
+
* @returns byte length
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
70
|
+
*
|
|
71
|
+
* var nbytes = z.byteLength;
|
|
72
|
+
* // returns 16
|
|
73
|
+
*/
|
|
74
|
+
readonly byteLength: 16;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Serializes a complex number as a string.
|
|
78
|
+
*
|
|
79
|
+
* @returns serialized complex number
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
83
|
+
*
|
|
84
|
+
* var str = z.toString();
|
|
85
|
+
* // returns '5 + 3i'
|
|
86
|
+
*/
|
|
87
|
+
toString(): string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Serializes a complex number as a JSON object.
|
|
91
|
+
*
|
|
92
|
+
* ## Notes
|
|
93
|
+
*
|
|
94
|
+
* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.
|
|
95
|
+
*
|
|
96
|
+
*
|
|
97
|
+
* @returns serialized complex number
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
101
|
+
*
|
|
102
|
+
* var obj = z.toJSON();
|
|
103
|
+
* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }
|
|
104
|
+
*/
|
|
105
|
+
toJSON(): any;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// EXPORTS //
|
|
110
|
+
|
|
111
|
+
export = Complex128;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2021 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef STDLIB_COMPLEX_FLOAT64_H
|
|
20
|
+
#define STDLIB_COMPLEX_FLOAT64_H
|
|
21
|
+
|
|
22
|
+
#include "stdlib/complex/float32.h"
|
|
23
|
+
#include <complex.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
28
|
+
*/
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
extern "C" {
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
// 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)
|
|
34
|
+
#if defined(_Imaginary_I) && defined(CMPLX)
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An opaque type definition for a double-precision complex floating-point number.
|
|
38
|
+
*/
|
|
39
|
+
typedef double complex stdlib_complex128_t;
|
|
40
|
+
|
|
41
|
+
// 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...
|
|
42
|
+
#else
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* An opaque type definition for a double-precision complex floating-point number.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* stdlib_complex128_t z;
|
|
49
|
+
*
|
|
50
|
+
* // Set the real component:
|
|
51
|
+
* z.re = 5.0;
|
|
52
|
+
*
|
|
53
|
+
* // Set the imaginary component:
|
|
54
|
+
* z.im = 2.0;
|
|
55
|
+
*/
|
|
56
|
+
typedef struct {
|
|
57
|
+
/**
|
|
58
|
+
* Real component.
|
|
59
|
+
*/
|
|
60
|
+
double re;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Imaginary component.
|
|
64
|
+
*/
|
|
65
|
+
double im;
|
|
66
|
+
} stdlib_complex128_t;
|
|
67
|
+
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* double real( const stdlib_complex128_t z ) {
|
|
75
|
+
* stdlib_complex128_parts_t v;
|
|
76
|
+
*
|
|
77
|
+
* // Assign a double-precision complex floating-point number:
|
|
78
|
+
* v.value = z;
|
|
79
|
+
*
|
|
80
|
+
* // Extract the real component:
|
|
81
|
+
* double re = v.parts[ 0 ];
|
|
82
|
+
*
|
|
83
|
+
* return re;
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* // ...
|
|
87
|
+
*
|
|
88
|
+
* // Create a complex number:
|
|
89
|
+
* stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 );
|
|
90
|
+
*
|
|
91
|
+
* // ...
|
|
92
|
+
*
|
|
93
|
+
* // Access the real component:
|
|
94
|
+
* double re = real( z );
|
|
95
|
+
* // returns 5.0
|
|
96
|
+
*/
|
|
97
|
+
typedef union {
|
|
98
|
+
// An opaque type for the output value (e.g., could be a `struct` or a C99 complex number):
|
|
99
|
+
stdlib_complex128_t value;
|
|
100
|
+
|
|
101
|
+
// Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see <https://en.cppreference.com/w/c/language/arithmetic_types#Complex_floating_types>), 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`):
|
|
102
|
+
double parts[ 2 ];
|
|
103
|
+
} stdlib_complex128_parts_t;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Returns a double-precision complex floating-point number.
|
|
107
|
+
*/
|
|
108
|
+
stdlib_complex128_t stdlib_complex128( const double real, const double imag );
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Converts a single-precision floating-point number to a double-precision complex floating-point number.
|
|
112
|
+
*/
|
|
113
|
+
stdlib_complex128_t stdlib_complex128_from_float32( const float real );
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Converts a double-precision floating-point number to a double-precision complex floating-point number.
|
|
117
|
+
*/
|
|
118
|
+
stdlib_complex128_t stdlib_complex128_from_float64( const double real );
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Converts a single-precision complex floating-point number to a double-precision complex floating-point number.
|
|
122
|
+
*/
|
|
123
|
+
stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z );
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number.
|
|
127
|
+
*/
|
|
128
|
+
stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z );
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Converts a signed 8-bit integer to a double-precision complex floating-point number.
|
|
132
|
+
*/
|
|
133
|
+
stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real );
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Converts an unsigned 8-bit integer to a double-precision complex floating-point number.
|
|
137
|
+
*/
|
|
138
|
+
stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real );
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Converts a signed 16-bit integer to a double-precision complex floating-point number.
|
|
142
|
+
*/
|
|
143
|
+
stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real );
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Converts an unsigned 16-bit integer to a double-precision complex floating-point number.
|
|
147
|
+
*/
|
|
148
|
+
stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real );
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Converts a signed 32-bit integer to a double-precision complex floating-point number.
|
|
152
|
+
*/
|
|
153
|
+
stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real );
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Converts an unsigned 32-bit integer to a double-precision complex floating-point number.
|
|
157
|
+
*/
|
|
158
|
+
stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real );
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Converts a double-precision complex floating-point number to a single-precision complex floating-point number.
|
|
162
|
+
*/
|
|
163
|
+
stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z );
|
|
164
|
+
|
|
165
|
+
#ifdef __cplusplus
|
|
166
|
+
}
|
|
167
|
+
#endif
|
|
168
|
+
|
|
169
|
+
#endif // !STDLIB_COMPLEX_FLOAT64_H
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 128-bit complex number constructor.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/complex-float64
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Complex128 = require( '@stdlib/complex-float64' );
|
|
28
|
+
*
|
|
29
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
30
|
+
* // returns <Complex128>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// MODULES //
|
|
34
|
+
|
|
35
|
+
var main = require( './main.js' );
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// EXPORTS //
|
|
39
|
+
|
|
40
|
+
module.exports = main;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;
|
|
24
|
+
var defineProperty = require( '@stdlib/utils-define-property' );
|
|
25
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
26
|
+
var format = require( '@stdlib/string-format' );
|
|
27
|
+
var toStr = require( './tostring.js' );
|
|
28
|
+
var toJSON = require( './tojson.js' );
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// MAIN //
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 128-bit complex number constructor.
|
|
35
|
+
*
|
|
36
|
+
* @constructor
|
|
37
|
+
* @param {number} real - real component
|
|
38
|
+
* @param {number} imag - imaginary component
|
|
39
|
+
* @throws {TypeError} must invoke using the `new` keyword
|
|
40
|
+
* @throws {TypeError} real component must be a number
|
|
41
|
+
* @throws {TypeError} imaginary component must be a number
|
|
42
|
+
* @returns {Complex128} 128-bit complex number
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
46
|
+
* // returns <Complex128>
|
|
47
|
+
*/
|
|
48
|
+
function Complex128( real, imag ) {
|
|
49
|
+
if ( !( this instanceof Complex128 ) ) {
|
|
50
|
+
throw new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );
|
|
51
|
+
}
|
|
52
|
+
if ( !isNumber( real ) ) {
|
|
53
|
+
throw new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );
|
|
54
|
+
}
|
|
55
|
+
if ( !isNumber( imag ) ) {
|
|
56
|
+
throw new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );
|
|
57
|
+
}
|
|
58
|
+
defineProperty( this, 're', {
|
|
59
|
+
'configurable': false,
|
|
60
|
+
'enumerable': true,
|
|
61
|
+
'writable': false,
|
|
62
|
+
'value': real
|
|
63
|
+
});
|
|
64
|
+
defineProperty( this, 'im', {
|
|
65
|
+
'configurable': false,
|
|
66
|
+
'enumerable': true,
|
|
67
|
+
'writable': false,
|
|
68
|
+
'value': imag
|
|
69
|
+
});
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Size (in bytes) of each component.
|
|
75
|
+
*
|
|
76
|
+
* @name BYTES_PER_ELEMENT
|
|
77
|
+
* @memberof Complex128
|
|
78
|
+
* @type {integer}
|
|
79
|
+
* @returns {integer} size of each component
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* var nbytes = Complex128.BYTES_PER_ELEMENT;
|
|
83
|
+
* // returns 8
|
|
84
|
+
*/
|
|
85
|
+
setReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Size (in bytes) of each component.
|
|
89
|
+
*
|
|
90
|
+
* @name BYTES_PER_ELEMENT
|
|
91
|
+
* @memberof Complex128.prototype
|
|
92
|
+
* @type {integer}
|
|
93
|
+
* @returns {integer} size of each component
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
97
|
+
*
|
|
98
|
+
* var nbytes = z.BYTES_PER_ELEMENT;
|
|
99
|
+
* // returns 8
|
|
100
|
+
*/
|
|
101
|
+
setReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Length (in bytes) of a complex number.
|
|
105
|
+
*
|
|
106
|
+
* @name byteLength
|
|
107
|
+
* @memberof Complex128.prototype
|
|
108
|
+
* @type {integer}
|
|
109
|
+
* @returns {integer} byte length
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
113
|
+
*
|
|
114
|
+
* var nbytes = z.byteLength;
|
|
115
|
+
* // returns 16
|
|
116
|
+
*/
|
|
117
|
+
setReadOnly( Complex128.prototype, 'byteLength', 16 );
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Serializes a complex number as a string.
|
|
121
|
+
*
|
|
122
|
+
* @name toString
|
|
123
|
+
* @memberof Complex128.prototype
|
|
124
|
+
* @type {Function}
|
|
125
|
+
* @returns {string} serialized complex number
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
129
|
+
*
|
|
130
|
+
* var str = z.toString();
|
|
131
|
+
* // returns '5 + 3i'
|
|
132
|
+
*/
|
|
133
|
+
setReadOnly( Complex128.prototype, 'toString', toStr );
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Serializes a complex number as a JSON object.
|
|
137
|
+
*
|
|
138
|
+
* ## Notes
|
|
139
|
+
*
|
|
140
|
+
* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.
|
|
141
|
+
*
|
|
142
|
+
* @name toJSON
|
|
143
|
+
* @memberof Complex128.prototype
|
|
144
|
+
* @type {Function}
|
|
145
|
+
* @returns {Object} serialized complex number
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* var z = new Complex128( 5.0, 3.0 );
|
|
149
|
+
*
|
|
150
|
+
* var obj = z.toJSON();
|
|
151
|
+
* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }
|
|
152
|
+
*/
|
|
153
|
+
setReadOnly( Complex128.prototype, 'toJSON', toJSON );
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// EXPORTS //
|
|
157
|
+
|
|
158
|
+
module.exports = Complex128;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Serializes a complex number as a JSON object.
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @returns {Object} JSON representation
|
|
26
|
+
*/
|
|
27
|
+
function toJSON() {
|
|
28
|
+
/* eslint-disable no-invalid-this */
|
|
29
|
+
var out = {};
|
|
30
|
+
out.type = 'Complex128';
|
|
31
|
+
out.re = this.re;
|
|
32
|
+
out.im = this.im;
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// EXPORTS //
|
|
38
|
+
|
|
39
|
+
module.exports = toJSON;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Serializes a complex number as a string.
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @returns {string} serialized complex number
|
|
26
|
+
*/
|
|
27
|
+
function toString() { // eslint-disable-line stdlib/no-redeclare
|
|
28
|
+
/* eslint-disable no-invalid-this */
|
|
29
|
+
var str = '' + this.re;
|
|
30
|
+
if ( this.im < 0 ) {
|
|
31
|
+
str += ' - ' + (-this.im);
|
|
32
|
+
} else {
|
|
33
|
+
str += ' + ' + this.im;
|
|
34
|
+
}
|
|
35
|
+
str += 'i';
|
|
36
|
+
return str;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// EXPORTS //
|
|
41
|
+
|
|
42
|
+
module.exports = toString;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {},
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"field": "src",
|
|
6
|
+
"resolve": true,
|
|
7
|
+
"relative": true
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"field": "include",
|
|
11
|
+
"resolve": true,
|
|
12
|
+
"relative": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"field": "libraries",
|
|
16
|
+
"resolve": false,
|
|
17
|
+
"relative": false
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"field": "libpath",
|
|
21
|
+
"resolve": true,
|
|
22
|
+
"relative": false
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"confs": [
|
|
26
|
+
{
|
|
27
|
+
"src": [
|
|
28
|
+
"./src/main.c"
|
|
29
|
+
],
|
|
30
|
+
"include": [
|
|
31
|
+
"./include"
|
|
32
|
+
],
|
|
33
|
+
"libraries": [],
|
|
34
|
+
"libpath": [],
|
|
35
|
+
"dependencies": [
|
|
36
|
+
"@stdlib/complex-float32"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|