@ohos-ports/stdlib-complex 0.0.0-stage → 0.4.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 +222 -2
- package/SECURITY.md +5 -0
- package/base/README.md +114 -0
- package/base/assert/README.md +108 -0
- package/base/assert/docs/types/index.d.ts +94 -0
- package/base/assert/docs/types/test.ts +29 -0
- package/base/assert/is-almost-equal/README.md +159 -0
- package/base/assert/is-almost-equal/docs/repl.txt +45 -0
- package/base/assert/is-almost-equal/docs/types/index.d.ts +56 -0
- package/base/assert/is-almost-equal/docs/types/test.ts +83 -0
- package/base/assert/is-almost-equal/lib/index.js +48 -0
- package/base/assert/is-almost-equal/lib/main.js +89 -0
- package/base/assert/is-almost-equal/package.json +73 -0
- package/base/assert/is-almost-same-value/README.md +159 -0
- package/base/assert/is-almost-same-value/docs/repl.txt +41 -0
- package/base/assert/is-almost-same-value/docs/types/index.d.ts +55 -0
- package/base/assert/is-almost-same-value/docs/types/test.ts +83 -0
- package/base/assert/is-almost-same-value/lib/index.js +48 -0
- package/base/assert/is-almost-same-value/lib/main.js +91 -0
- package/base/assert/is-almost-same-value/package.json +73 -0
- package/base/assert/lib/index.js +60 -0
- package/base/assert/package.json +62 -0
- package/base/cast-return/README.md +128 -0
- package/base/cast-return/docs/repl.txt +41 -0
- package/base/cast-return/docs/types/index.d.ts +378 -0
- package/base/cast-return/docs/types/test.ts +192 -0
- package/base/cast-return/lib/index.js +46 -0
- package/base/cast-return/lib/main.js +204 -0
- package/base/cast-return/package.json +65 -0
- package/base/docs/types/index.d.ts +130 -0
- package/base/docs/types/test.ts +29 -0
- package/base/lib/index.js +78 -0
- package/base/package.json +61 -0
- package/base/parse/README.md +137 -0
- package/base/parse/docs/repl.txt +21 -0
- package/base/parse/docs/types/index.d.ts +42 -0
- package/base/parse/docs/types/test.ts +34 -0
- package/base/parse/lib/index.js +42 -0
- package/base/parse/lib/main.js +124 -0
- package/base/parse/package.json +71 -0
- package/base/wrap-function/README.md +128 -0
- package/base/wrap-function/docs/repl.txt +43 -0
- package/base/wrap-function/docs/types/index.d.ts +417 -0
- package/base/wrap-function/docs/types/test.ts +629 -0
- package/base/wrap-function/lib/index.js +46 -0
- package/base/wrap-function/lib/main.js +225 -0
- package/base/wrap-function/package.json +63 -0
- package/cmplx/README.md +137 -0
- package/cmplx/docs/repl.txt +35 -0
- package/cmplx/docs/types/index.d.ts +44 -0
- package/cmplx/docs/types/test.ts +66 -0
- package/cmplx/lib/index.js +40 -0
- package/cmplx/lib/main.js +66 -0
- package/cmplx/package.json +63 -0
- package/ctors/README.md +136 -0
- package/ctors/docs/repl.txt +29 -0
- package/ctors/docs/types/index.d.ts +67 -0
- package/ctors/docs/types/test.ts +35 -0
- package/ctors/lib/ctors.js +38 -0
- package/ctors/lib/index.js +43 -0
- package/ctors/lib/main.js +49 -0
- package/ctors/package.json +72 -0
- package/docs/types/index.d.ts +151 -0
- package/dtype/README.md +142 -0
- package/dtype/docs/repl.txt +28 -0
- package/dtype/docs/types/index.d.ts +82 -0
- package/dtype/docs/types/test.ts +36 -0
- package/dtype/lib/ctor2dtype.js +32 -0
- package/dtype/lib/ctors.js +38 -0
- package/dtype/lib/dtypes.js +33 -0
- package/dtype/lib/index.js +49 -0
- package/dtype/lib/main.js +65 -0
- package/dtype/package.json +67 -0
- package/dtypes/README.md +142 -0
- package/dtypes/docs/repl.txt +22 -0
- package/dtypes/docs/types/index.d.ts +39 -0
- package/dtypes/docs/types/test.ts +33 -0
- package/dtypes/lib/dtypes.json +4 -0
- package/dtypes/lib/index.js +40 -0
- package/dtypes/lib/main.js +44 -0
- package/dtypes/package.json +68 -0
- package/float32/README.md +137 -0
- package/float32/base/README.md +140 -0
- package/float32/base/add/README.md +279 -0
- package/float32/base/add/docs/repl.txt +118 -0
- package/float32/base/add/docs/types/index.d.ts +136 -0
- package/float32/base/add/docs/types/test.ts +356 -0
- package/float32/base/add/include/stdlib/complex/float32/base/add.h +40 -0
- package/float32/base/add/lib/assign.js +55 -0
- package/float32/base/add/lib/index.js +54 -0
- package/float32/base/add/lib/main.js +55 -0
- package/float32/base/add/lib/native.js +53 -0
- package/float32/base/add/lib/strided.js +60 -0
- package/float32/base/add/manifest.json +75 -0
- package/float32/base/add/package.json +69 -0
- package/float32/base/add/src/addon.c +22 -0
- package/float32/base/add/src/main.c +60 -0
- package/float32/base/add3/README.md +275 -0
- package/float32/base/add3/docs/repl.txt +133 -0
- package/float32/base/add3/docs/types/index.d.ts +145 -0
- package/float32/base/add3/docs/types/test.ts +465 -0
- package/float32/base/add3/include/stdlib/complex/float32/base/add3.h +40 -0
- package/float32/base/add3/lib/assign.js +57 -0
- package/float32/base/add3/lib/index.js +54 -0
- package/float32/base/add3/lib/main.js +56 -0
- package/float32/base/add3/lib/native.js +54 -0
- package/float32/base/add3/lib/strided.js +64 -0
- package/float32/base/add3/manifest.json +75 -0
- package/float32/base/add3/package.json +69 -0
- package/float32/base/add3/src/addon.c +22 -0
- package/float32/base/add3/src/main.c +64 -0
- package/float32/base/assert/README.md +120 -0
- package/float32/base/assert/docs/types/index.d.ts +181 -0
- package/float32/base/assert/docs/types/test.ts +29 -0
- package/float32/base/assert/is-almost-equal/README.md +158 -0
- package/float32/base/assert/is-almost-equal/docs/repl.txt +45 -0
- package/float32/base/assert/is-almost-equal/docs/types/index.d.ts +56 -0
- package/float32/base/assert/is-almost-equal/docs/types/test.ts +83 -0
- package/float32/base/assert/is-almost-equal/lib/index.js +48 -0
- package/float32/base/assert/is-almost-equal/lib/main.js +67 -0
- package/float32/base/assert/is-almost-equal/package.json +73 -0
- package/float32/base/assert/is-almost-same-value/README.md +158 -0
- package/float32/base/assert/is-almost-same-value/docs/repl.txt +43 -0
- package/float32/base/assert/is-almost-same-value/docs/types/index.d.ts +55 -0
- package/float32/base/assert/is-almost-same-value/docs/types/test.ts +83 -0
- package/float32/base/assert/is-almost-same-value/lib/index.js +48 -0
- package/float32/base/assert/is-almost-same-value/lib/main.js +69 -0
- package/float32/base/assert/is-almost-same-value/package.json +74 -0
- package/float32/base/assert/is-equal/README.md +221 -0
- package/float32/base/assert/is-equal/docs/repl.txt +27 -0
- package/float32/base/assert/is-equal/docs/types/index.d.ts +46 -0
- package/float32/base/assert/is-equal/docs/types/test.ts +67 -0
- package/float32/base/assert/is-equal/include/stdlib/complex/float32/base/assert/is_equal.h +41 -0
- package/float32/base/assert/is-equal/lib/index.js +44 -0
- package/float32/base/assert/is-equal/lib/main.js +56 -0
- package/float32/base/assert/is-equal/manifest.json +59 -0
- package/float32/base/assert/is-equal/package.json +71 -0
- package/float32/base/assert/is-equal/src/main.c +48 -0
- package/float32/base/assert/is-not-equal/README.md +221 -0
- package/float32/base/assert/is-not-equal/docs/repl.txt +28 -0
- package/float32/base/assert/is-not-equal/docs/types/index.d.ts +46 -0
- package/float32/base/assert/is-not-equal/docs/types/test.ts +67 -0
- package/float32/base/assert/is-not-equal/include/stdlib/complex/float32/base/assert/is_not_equal.h +41 -0
- package/float32/base/assert/is-not-equal/lib/index.js +44 -0
- package/float32/base/assert/is-not-equal/lib/main.js +56 -0
- package/float32/base/assert/is-not-equal/manifest.json +59 -0
- package/float32/base/assert/is-not-equal/package.json +72 -0
- package/float32/base/assert/is-not-equal/src/main.c +48 -0
- package/float32/base/assert/is-same-value/README.md +245 -0
- package/float32/base/assert/is-same-value/docs/repl.txt +31 -0
- package/float32/base/assert/is-same-value/docs/types/index.d.ts +53 -0
- package/float32/base/assert/is-same-value/docs/types/test.ts +67 -0
- package/float32/base/assert/is-same-value/include/stdlib/complex/float32/base/assert/is_same_value.h +41 -0
- package/float32/base/assert/is-same-value/lib/index.js +44 -0
- package/float32/base/assert/is-same-value/lib/main.js +64 -0
- package/float32/base/assert/is-same-value/manifest.json +61 -0
- package/float32/base/assert/is-same-value/package.json +74 -0
- package/float32/base/assert/is-same-value/src/main.c +52 -0
- package/float32/base/assert/is-same-value-zero/README.md +247 -0
- package/float32/base/assert/is-same-value-zero/docs/repl.txt +31 -0
- package/float32/base/assert/is-same-value-zero/docs/types/index.d.ts +50 -0
- package/float32/base/assert/is-same-value-zero/docs/types/test.ts +67 -0
- package/float32/base/assert/is-same-value-zero/include/stdlib/complex/float32/base/assert/is_same_value_zero.h +41 -0
- package/float32/base/assert/is-same-value-zero/lib/index.js +44 -0
- package/float32/base/assert/is-same-value-zero/lib/main.js +62 -0
- package/float32/base/assert/is-same-value-zero/manifest.json +61 -0
- package/float32/base/assert/is-same-value-zero/package.json +74 -0
- package/float32/base/assert/is-same-value-zero/src/main.c +52 -0
- package/float32/base/assert/lib/index.js +96 -0
- package/float32/base/assert/package.json +63 -0
- package/float32/base/docs/types/index.d.ts +297 -0
- package/float32/base/docs/types/test.ts +29 -0
- package/float32/base/identity/README.md +233 -0
- package/float32/base/identity/docs/img/equation_identity_function.svg +18 -0
- package/float32/base/identity/docs/repl.txt +27 -0
- package/float32/base/identity/docs/types/index.d.ts +42 -0
- package/float32/base/identity/docs/types/test.ts +45 -0
- package/float32/base/identity/include/stdlib/complex/float32/base/identity.h +40 -0
- package/float32/base/identity/lib/index.js +41 -0
- package/float32/base/identity/lib/main.js +42 -0
- package/float32/base/identity/lib/native.js +50 -0
- package/float32/base/identity/manifest.json +75 -0
- package/float32/base/identity/package.json +68 -0
- package/float32/base/identity/src/addon.c +22 -0
- package/float32/base/identity/src/main.c +44 -0
- package/float32/base/lib/index.js +123 -0
- package/float32/base/mul/README.md +281 -0
- package/float32/base/mul/docs/repl.txt +120 -0
- package/float32/base/mul/docs/types/index.d.ts +138 -0
- package/float32/base/mul/docs/types/test.ts +356 -0
- package/float32/base/mul/include/stdlib/complex/float32/base/mul.h +40 -0
- package/float32/base/mul/lib/assign.js +55 -0
- package/float32/base/mul/lib/index.js +55 -0
- package/float32/base/mul/lib/main.js +60 -0
- package/float32/base/mul/lib/native.js +54 -0
- package/float32/base/mul/lib/strided.js +64 -0
- package/float32/base/mul/manifest.json +95 -0
- package/float32/base/mul/package.json +69 -0
- package/float32/base/mul/src/addon.c +22 -0
- package/float32/base/mul/src/main.c +61 -0
- package/float32/base/mul-add/README.md +286 -0
- package/float32/base/mul-add/docs/repl.txt +141 -0
- package/float32/base/mul-add/docs/types/index.d.ts +151 -0
- package/float32/base/mul-add/docs/types/test.ts +465 -0
- package/float32/base/mul-add/include/stdlib/complex/float32/base/mul_add.h +40 -0
- package/float32/base/mul-add/lib/assign.js +57 -0
- package/float32/base/mul-add/lib/index.js +56 -0
- package/float32/base/mul-add/lib/main.js +64 -0
- package/float32/base/mul-add/lib/native.js +56 -0
- package/float32/base/mul-add/lib/strided.js +70 -0
- package/float32/base/mul-add/manifest.json +75 -0
- package/float32/base/mul-add/package.json +70 -0
- package/float32/base/mul-add/src/addon.c +22 -0
- package/float32/base/mul-add/src/main.c +66 -0
- package/float32/base/neg/README.md +259 -0
- package/float32/base/neg/docs/repl.txt +28 -0
- package/float32/base/neg/docs/types/index.d.ts +60 -0
- package/float32/base/neg/docs/types/test.ts +51 -0
- package/float32/base/neg/include/stdlib/complex/float32/base/neg.h +40 -0
- package/float32/base/neg/lib/index.js +61 -0
- package/float32/base/neg/lib/main.js +67 -0
- package/float32/base/neg/lib/native.js +68 -0
- package/float32/base/neg/manifest.json +75 -0
- package/float32/base/neg/package.json +67 -0
- package/float32/base/neg/src/addon.c +22 -0
- package/float32/base/neg/src/main.c +50 -0
- package/float32/base/package.json +67 -0
- package/float32/base/scale/README.md +263 -0
- package/float32/base/scale/docs/repl.txt +110 -0
- package/float32/base/scale/docs/types/index.d.ts +131 -0
- package/float32/base/scale/docs/types/test.ts +296 -0
- package/float32/base/scale/include/stdlib/complex/float32/base/scale.h +40 -0
- package/float32/base/scale/lib/assign.js +54 -0
- package/float32/base/scale/lib/index.js +54 -0
- package/float32/base/scale/lib/main.js +53 -0
- package/float32/base/scale/lib/native.js +53 -0
- package/float32/base/scale/lib/strided.js +57 -0
- package/float32/base/scale/manifest.json +75 -0
- package/float32/base/scale/package.json +69 -0
- package/float32/base/scale/src/addon.c +22 -0
- package/float32/base/scale/src/main.c +51 -0
- package/float32/base/sub/README.md +225 -0
- package/float32/base/sub/docs/repl.txt +33 -0
- package/float32/base/sub/docs/types/index.d.ts +46 -0
- package/float32/base/sub/docs/types/test.ts +67 -0
- package/float32/base/sub/include/stdlib/complex/float32/base/sub.h +40 -0
- package/float32/base/sub/lib/index.js +44 -0
- package/float32/base/sub/lib/main.js +56 -0
- package/float32/base/sub/lib/native.js +54 -0
- package/float32/base/sub/manifest.json +75 -0
- package/float32/base/sub/package.json +72 -0
- package/float32/base/sub/src/addon.c +22 -0
- package/float32/base/sub/src/main.c +62 -0
- package/float32/conj/README.md +258 -0
- package/float32/conj/docs/repl.txt +27 -0
- package/float32/conj/docs/types/index.d.ts +42 -0
- package/float32/conj/docs/types/test.ts +45 -0
- package/float32/conj/include/stdlib/complex/float32/conj.h +40 -0
- package/float32/conj/lib/index.js +43 -0
- package/float32/conj/lib/main.js +42 -0
- package/float32/conj/manifest.json +75 -0
- package/float32/conj/package.json +64 -0
- package/float32/conj/src/main.c +49 -0
- package/float32/ctor/README.md +547 -0
- package/float32/ctor/docs/repl.txt +93 -0
- package/float32/ctor/docs/types/index.d.ts +120 -0
- package/float32/ctor/docs/types/test.ts +59 -0
- package/float32/ctor/include/stdlib/complex/float32/ctor.h +148 -0
- package/float32/ctor/lib/index.js +40 -0
- package/float32/ctor/lib/main.js +164 -0
- package/float32/ctor/lib/tojson.js +39 -0
- package/float32/ctor/lib/tostring.js +42 -0
- package/float32/ctor/manifest.json +38 -0
- package/float32/ctor/package.json +70 -0
- package/float32/ctor/src/main.c +151 -0
- package/float32/docs/types/index.d.ts +151 -0
- package/float32/docs/types/test.ts +29 -0
- package/float32/imag/README.md +239 -0
- package/float32/imag/docs/repl.txt +24 -0
- package/float32/imag/docs/types/index.d.ts +44 -0
- package/float32/imag/docs/types/test.ts +45 -0
- package/float32/imag/include/stdlib/complex/float32/imag.h +40 -0
- package/float32/imag/lib/index.js +43 -0
- package/float32/imag/lib/main.js +42 -0
- package/float32/imag/manifest.json +40 -0
- package/float32/imag/package.json +67 -0
- package/float32/imag/src/main.c +42 -0
- package/float32/lib/index.js +114 -0
- package/float32/package.json +61 -0
- package/float32/parse/README.md +133 -0
- package/float32/parse/docs/repl.txt +22 -0
- package/float32/parse/docs/types/index.d.ts +46 -0
- package/float32/parse/docs/types/test.ts +44 -0
- package/float32/parse/lib/index.js +42 -0
- package/float32/parse/lib/main.js +90 -0
- package/float32/parse/package.json +67 -0
- package/float32/real/README.md +239 -0
- package/float32/real/docs/repl.txt +24 -0
- package/float32/real/docs/types/index.d.ts +44 -0
- package/float32/real/docs/types/test.ts +45 -0
- package/float32/real/include/stdlib/complex/float32/real.h +40 -0
- package/float32/real/lib/index.js +43 -0
- package/float32/real/lib/main.js +42 -0
- package/float32/real/manifest.json +40 -0
- package/float32/real/package.json +67 -0
- package/float32/real/src/main.c +42 -0
- package/float32/reim/README.md +248 -0
- package/float32/reim/docs/repl.txt +24 -0
- package/float32/reim/docs/types/index.d.ts +44 -0
- package/float32/reim/docs/types/test.ts +45 -0
- package/float32/reim/include/stdlib/complex/float32/reim.h +40 -0
- package/float32/reim/lib/index.js +43 -0
- package/float32/reim/lib/main.js +52 -0
- package/float32/reim/manifest.json +40 -0
- package/float32/reim/package.json +67 -0
- package/float32/reim/src/main.c +46 -0
- package/float32/reviver/README.md +145 -0
- package/float32/reviver/docs/repl.txt +26 -0
- package/float32/reviver/docs/types/index.d.ts +41 -0
- package/float32/reviver/docs/types/test.ts +50 -0
- package/float32/reviver/lib/index.js +43 -0
- package/float32/reviver/lib/main.js +60 -0
- package/float32/reviver/package.json +72 -0
- package/float64/README.md +137 -0
- package/float64/base/README.md +143 -0
- package/float64/base/add/README.md +279 -0
- package/float64/base/add/docs/repl.txt +118 -0
- package/float64/base/add/docs/types/index.d.ts +136 -0
- package/float64/base/add/docs/types/test.ts +357 -0
- package/float64/base/add/include/stdlib/complex/float64/base/add.h +40 -0
- package/float64/base/add/lib/assign.js +50 -0
- package/float64/base/add/lib/index.js +54 -0
- package/float64/base/add/lib/main.js +54 -0
- package/float64/base/add/lib/native.js +53 -0
- package/float64/base/add/lib/strided.js +55 -0
- package/float64/base/add/manifest.json +75 -0
- package/float64/base/add/package.json +68 -0
- package/float64/base/add/src/addon.c +22 -0
- package/float64/base/add/src/main.c +60 -0
- package/float64/base/add3/README.md +275 -0
- package/float64/base/add3/docs/repl.txt +133 -0
- package/float64/base/add3/docs/types/index.d.ts +145 -0
- package/float64/base/add3/docs/types/test.ts +467 -0
- package/float64/base/add3/include/stdlib/complex/float64/base/add3.h +40 -0
- package/float64/base/add3/lib/assign.js +52 -0
- package/float64/base/add3/lib/index.js +54 -0
- package/float64/base/add3/lib/main.js +55 -0
- package/float64/base/add3/lib/native.js +54 -0
- package/float64/base/add3/lib/strided.js +59 -0
- package/float64/base/add3/manifest.json +75 -0
- package/float64/base/add3/package.json +68 -0
- package/float64/base/add3/src/addon.c +22 -0
- package/float64/base/add3/src/main.c +64 -0
- package/float64/base/assert/README.md +120 -0
- package/float64/base/assert/docs/types/index.d.ts +181 -0
- package/float64/base/assert/docs/types/test.ts +29 -0
- package/float64/base/assert/is-almost-equal/README.md +158 -0
- package/float64/base/assert/is-almost-equal/docs/repl.txt +45 -0
- package/float64/base/assert/is-almost-equal/docs/types/index.d.ts +56 -0
- package/float64/base/assert/is-almost-equal/docs/types/test.ts +83 -0
- package/float64/base/assert/is-almost-equal/lib/index.js +48 -0
- package/float64/base/assert/is-almost-equal/lib/main.js +67 -0
- package/float64/base/assert/is-almost-equal/package.json +73 -0
- package/float64/base/assert/is-almost-same-value/README.md +158 -0
- package/float64/base/assert/is-almost-same-value/docs/repl.txt +43 -0
- package/float64/base/assert/is-almost-same-value/docs/types/index.d.ts +55 -0
- package/float64/base/assert/is-almost-same-value/docs/types/test.ts +83 -0
- package/float64/base/assert/is-almost-same-value/lib/index.js +48 -0
- package/float64/base/assert/is-almost-same-value/lib/main.js +69 -0
- package/float64/base/assert/is-almost-same-value/package.json +74 -0
- package/float64/base/assert/is-equal/README.md +221 -0
- package/float64/base/assert/is-equal/docs/repl.txt +27 -0
- package/float64/base/assert/is-equal/docs/types/index.d.ts +46 -0
- package/float64/base/assert/is-equal/docs/types/test.ts +67 -0
- package/float64/base/assert/is-equal/include/stdlib/complex/float64/base/assert/is_equal.h +41 -0
- package/float64/base/assert/is-equal/lib/index.js +44 -0
- package/float64/base/assert/is-equal/lib/main.js +56 -0
- package/float64/base/assert/is-equal/manifest.json +59 -0
- package/float64/base/assert/is-equal/package.json +71 -0
- package/float64/base/assert/is-equal/src/main.c +48 -0
- package/float64/base/assert/is-not-equal/README.md +221 -0
- package/float64/base/assert/is-not-equal/docs/repl.txt +28 -0
- package/float64/base/assert/is-not-equal/docs/types/index.d.ts +46 -0
- package/float64/base/assert/is-not-equal/docs/types/test.ts +67 -0
- package/float64/base/assert/is-not-equal/include/stdlib/complex/float64/base/assert/is_not_equal.h +41 -0
- package/float64/base/assert/is-not-equal/lib/index.js +44 -0
- package/float64/base/assert/is-not-equal/lib/main.js +56 -0
- package/float64/base/assert/is-not-equal/manifest.json +59 -0
- package/float64/base/assert/is-not-equal/package.json +72 -0
- package/float64/base/assert/is-not-equal/src/main.c +48 -0
- package/float64/base/assert/is-same-value/README.md +245 -0
- package/float64/base/assert/is-same-value/docs/repl.txt +31 -0
- package/float64/base/assert/is-same-value/docs/types/index.d.ts +53 -0
- package/float64/base/assert/is-same-value/docs/types/test.ts +67 -0
- package/float64/base/assert/is-same-value/include/stdlib/complex/float64/base/assert/is_same_value.h +41 -0
- package/float64/base/assert/is-same-value/lib/index.js +44 -0
- package/float64/base/assert/is-same-value/lib/main.js +64 -0
- package/float64/base/assert/is-same-value/manifest.json +61 -0
- package/float64/base/assert/is-same-value/package.json +74 -0
- package/float64/base/assert/is-same-value/src/main.c +52 -0
- package/float64/base/assert/is-same-value-zero/README.md +247 -0
- package/float64/base/assert/is-same-value-zero/docs/repl.txt +31 -0
- package/float64/base/assert/is-same-value-zero/docs/types/index.d.ts +50 -0
- package/float64/base/assert/is-same-value-zero/docs/types/test.ts +67 -0
- package/float64/base/assert/is-same-value-zero/include/stdlib/complex/float64/base/assert/is_same_value_zero.h +41 -0
- package/float64/base/assert/is-same-value-zero/lib/index.js +44 -0
- package/float64/base/assert/is-same-value-zero/lib/main.js +62 -0
- package/float64/base/assert/is-same-value-zero/manifest.json +61 -0
- package/float64/base/assert/is-same-value-zero/package.json +74 -0
- package/float64/base/assert/is-same-value-zero/src/main.c +52 -0
- package/float64/base/assert/lib/index.js +96 -0
- package/float64/base/assert/package.json +63 -0
- package/float64/base/div/README.md +304 -0
- package/float64/base/div/docs/repl.txt +119 -0
- package/float64/base/div/docs/types/index.d.ts +119 -0
- package/float64/base/div/docs/types/test.ts +357 -0
- package/float64/base/div/include/stdlib/complex/float64/base/div.h +40 -0
- package/float64/base/div/lib/assign.js +106 -0
- package/float64/base/div/lib/index.js +55 -0
- package/float64/base/div/lib/internal_compreal.js +56 -0
- package/float64/base/div/lib/main.js +76 -0
- package/float64/base/div/lib/native.js +54 -0
- package/float64/base/div/lib/robust_internal.js +61 -0
- package/float64/base/div/lib/strided.js +58 -0
- package/float64/base/div/manifest.json +87 -0
- package/float64/base/div/package.json +68 -0
- package/float64/base/div/src/addon.c +22 -0
- package/float64/base/div/src/main.c +173 -0
- package/float64/base/docs/types/index.d.ts +316 -0
- package/float64/base/docs/types/test.ts +29 -0
- package/float64/base/identity/README.md +235 -0
- package/float64/base/identity/docs/img/equation_identity_function.svg +18 -0
- package/float64/base/identity/docs/repl.txt +27 -0
- package/float64/base/identity/docs/types/index.d.ts +42 -0
- package/float64/base/identity/docs/types/test.ts +45 -0
- package/float64/base/identity/include/stdlib/complex/float64/base/identity.h +40 -0
- package/float64/base/identity/lib/index.js +41 -0
- package/float64/base/identity/lib/main.js +42 -0
- package/float64/base/identity/lib/native.js +50 -0
- package/float64/base/identity/manifest.json +75 -0
- package/float64/base/identity/package.json +68 -0
- package/float64/base/identity/src/addon.c +22 -0
- package/float64/base/identity/src/main.c +44 -0
- package/float64/base/lib/index.js +132 -0
- package/float64/base/mul/README.md +288 -0
- package/float64/base/mul/docs/repl.txt +120 -0
- package/float64/base/mul/docs/types/index.d.ts +138 -0
- package/float64/base/mul/docs/types/test.ts +358 -0
- package/float64/base/mul/include/stdlib/complex/float64/base/mul.h +40 -0
- package/float64/base/mul/lib/assign.js +50 -0
- package/float64/base/mul/lib/index.js +55 -0
- package/float64/base/mul/lib/main.js +59 -0
- package/float64/base/mul/lib/native.js +54 -0
- package/float64/base/mul/lib/strided.js +59 -0
- package/float64/base/mul/manifest.json +95 -0
- package/float64/base/mul/package.json +69 -0
- package/float64/base/mul/src/addon.c +22 -0
- package/float64/base/mul/src/main.c +61 -0
- package/float64/base/mul-add/README.md +286 -0
- package/float64/base/mul-add/docs/repl.txt +142 -0
- package/float64/base/mul-add/docs/types/index.d.ts +151 -0
- package/float64/base/mul-add/docs/types/test.ts +467 -0
- package/float64/base/mul-add/include/stdlib/complex/float64/base/mul_add.h +40 -0
- package/float64/base/mul-add/lib/assign.js +52 -0
- package/float64/base/mul-add/lib/index.js +56 -0
- package/float64/base/mul-add/lib/main.js +63 -0
- package/float64/base/mul-add/lib/native.js +56 -0
- package/float64/base/mul-add/lib/strided.js +65 -0
- package/float64/base/mul-add/manifest.json +75 -0
- package/float64/base/mul-add/package.json +70 -0
- package/float64/base/mul-add/src/addon.c +22 -0
- package/float64/base/mul-add/src/main.c +66 -0
- package/float64/base/neg/README.md +257 -0
- package/float64/base/neg/docs/repl.txt +28 -0
- package/float64/base/neg/docs/types/index.d.ts +60 -0
- package/float64/base/neg/docs/types/test.ts +51 -0
- package/float64/base/neg/include/stdlib/complex/float64/base/neg.h +40 -0
- package/float64/base/neg/lib/index.js +61 -0
- package/float64/base/neg/lib/main.js +67 -0
- package/float64/base/neg/lib/native.js +68 -0
- package/float64/base/neg/manifest.json +75 -0
- package/float64/base/neg/package.json +67 -0
- package/float64/base/neg/src/addon.c +22 -0
- package/float64/base/neg/src/main.c +49 -0
- package/float64/base/package.json +67 -0
- package/float64/base/scale/README.md +263 -0
- package/float64/base/scale/docs/repl.txt +106 -0
- package/float64/base/scale/docs/types/index.d.ts +131 -0
- package/float64/base/scale/docs/types/test.ts +297 -0
- package/float64/base/scale/include/stdlib/complex/float64/base/scale.h +40 -0
- package/float64/base/scale/lib/assign.js +49 -0
- package/float64/base/scale/lib/index.js +54 -0
- package/float64/base/scale/lib/main.js +52 -0
- package/float64/base/scale/lib/native.js +53 -0
- package/float64/base/scale/lib/strided.js +52 -0
- package/float64/base/scale/manifest.json +75 -0
- package/float64/base/scale/package.json +69 -0
- package/float64/base/scale/src/addon.c +22 -0
- package/float64/base/scale/src/main.c +51 -0
- package/float64/base/sub/README.md +226 -0
- package/float64/base/sub/docs/repl.txt +33 -0
- package/float64/base/sub/docs/types/index.d.ts +46 -0
- package/float64/base/sub/docs/types/test.ts +67 -0
- package/float64/base/sub/include/stdlib/complex/float64/base/sub.h +40 -0
- package/float64/base/sub/lib/index.js +44 -0
- package/float64/base/sub/lib/main.js +55 -0
- package/float64/base/sub/lib/native.js +54 -0
- package/float64/base/sub/manifest.json +75 -0
- package/float64/base/sub/package.json +71 -0
- package/float64/base/sub/src/addon.c +22 -0
- package/float64/base/sub/src/main.c +61 -0
- package/float64/conj/README.md +255 -0
- package/float64/conj/docs/repl.txt +27 -0
- package/float64/conj/docs/types/index.d.ts +42 -0
- package/float64/conj/docs/types/test.ts +45 -0
- package/float64/conj/include/stdlib/complex/float64/conj.h +40 -0
- package/float64/conj/lib/index.js +43 -0
- package/float64/conj/lib/main.js +48 -0
- package/float64/conj/lib/native.js +52 -0
- package/float64/conj/manifest.json +76 -0
- package/float64/conj/package.json +65 -0
- package/float64/conj/src/addon.c +22 -0
- package/float64/conj/src/main.c +49 -0
- package/float64/ctor/README.md +617 -0
- package/float64/ctor/docs/repl.txt +84 -0
- package/float64/ctor/docs/types/index.d.ts +120 -0
- package/float64/ctor/docs/types/test.ts +69 -0
- package/float64/ctor/include/stdlib/complex/float64/ctor.h +169 -0
- package/float64/ctor/lib/index.js +40 -0
- package/float64/ctor/lib/main.js +163 -0
- package/float64/ctor/lib/tojson.js +39 -0
- package/float64/ctor/lib/tostring.js +42 -0
- package/float64/ctor/manifest.json +40 -0
- package/float64/ctor/package.json +69 -0
- package/float64/ctor/src/main.c +224 -0
- package/float64/docs/types/index.d.ts +151 -0
- package/float64/docs/types/test.ts +29 -0
- package/float64/imag/README.md +236 -0
- package/float64/imag/docs/repl.txt +24 -0
- package/float64/imag/docs/types/index.d.ts +44 -0
- package/float64/imag/docs/types/test.ts +45 -0
- package/float64/imag/include/stdlib/complex/float64/imag.h +40 -0
- package/float64/imag/lib/index.js +43 -0
- package/float64/imag/lib/main.js +42 -0
- package/float64/imag/manifest.json +40 -0
- package/float64/imag/package.json +67 -0
- package/float64/imag/src/main.c +42 -0
- package/float64/lib/index.js +114 -0
- package/float64/package.json +61 -0
- package/float64/parse/README.md +132 -0
- package/float64/parse/docs/repl.txt +23 -0
- package/float64/parse/docs/types/index.d.ts +46 -0
- package/float64/parse/docs/types/test.ts +44 -0
- package/float64/parse/lib/index.js +42 -0
- package/float64/parse/lib/main.js +90 -0
- package/float64/parse/package.json +67 -0
- package/float64/real/README.md +236 -0
- package/float64/real/docs/repl.txt +24 -0
- package/float64/real/docs/types/index.d.ts +44 -0
- package/float64/real/docs/types/test.ts +45 -0
- package/float64/real/include/stdlib/complex/float64/real.h +40 -0
- package/float64/real/lib/index.js +43 -0
- package/float64/real/lib/main.js +42 -0
- package/float64/real/manifest.json +40 -0
- package/float64/real/package.json +67 -0
- package/float64/real/src/main.c +42 -0
- package/float64/reim/README.md +245 -0
- package/float64/reim/docs/repl.txt +24 -0
- package/float64/reim/docs/types/index.d.ts +44 -0
- package/float64/reim/docs/types/test.ts +45 -0
- package/float64/reim/include/stdlib/complex/float64/reim.h +40 -0
- package/float64/reim/lib/index.js +43 -0
- package/float64/reim/lib/main.js +52 -0
- package/float64/reim/manifest.json +40 -0
- package/float64/reim/package.json +67 -0
- package/float64/reim/src/main.c +46 -0
- package/float64/reviver/README.md +145 -0
- package/float64/reviver/docs/repl.txt +26 -0
- package/float64/reviver/docs/types/index.d.ts +41 -0
- package/float64/reviver/docs/types/test.ts +50 -0
- package/float64/reviver/lib/index.js +43 -0
- package/float64/reviver/lib/main.js +60 -0
- package/float64/reviver/package.json +72 -0
- package/lib/index.js +123 -0
- package/package.json +71 -4
- package/promotion-rules/README.md +164 -0
- package/promotion-rules/docs/repl.txt +33 -0
- package/promotion-rules/docs/types/index.d.ts +102 -0
- package/promotion-rules/docs/types/test.ts +66 -0
- package/promotion-rules/lib/index.js +46 -0
- package/promotion-rules/lib/main.js +102 -0
- package/promotion-rules/lib/promotion_rules.json +64 -0
- package/promotion-rules/package.json +69 -0
- package/reviver/README.md +148 -0
- package/reviver/docs/repl.txt +33 -0
- package/reviver/docs/types/index.d.ts +41 -0
- package/reviver/docs/types/test.ts +45 -0
- package/reviver/lib/ctors.js +37 -0
- package/reviver/lib/index.js +43 -0
- package/reviver/lib/main.js +63 -0
- package/reviver/package.json +73 -0
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
/* eslint-disable valid-typeof */
|
|
20
|
+
|
|
21
|
+
'use strict';
|
|
22
|
+
|
|
23
|
+
// MODULES //
|
|
24
|
+
|
|
25
|
+
var isFunction = require( '@stdlib/assert/is-function' );
|
|
26
|
+
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
|
|
27
|
+
var format = require( '@stdlib/string/format' );
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// VARIABLES //
|
|
31
|
+
|
|
32
|
+
var T = 'number';
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// FUNCTIONS //
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Wraps a function accepting complex number arguments to support providing both real and complex numbers.
|
|
39
|
+
*
|
|
40
|
+
* ## Notes
|
|
41
|
+
*
|
|
42
|
+
* - The returned function **assumes** that the wrapped function accepts **only** complex number input arguments (i.e., every argument must be a complex number).
|
|
43
|
+
* - The returned function **assumes** that, if an input argument is non-numeric (i.e., not of type `number`), then the input argument is a complex number. The returned function does **not** verify that non-numeric input arguments are, in fact, complex number objects. The returned function passes non-numeric input arguments to the wrapped function without modification.
|
|
44
|
+
*
|
|
45
|
+
* @param {Function} fcn - function to wrap
|
|
46
|
+
* @param {NonNegativeInteger} nargs - number of arguments
|
|
47
|
+
* @param {Function} ctor - complex number constructor
|
|
48
|
+
* @throws {TypeError} first argument must be a function
|
|
49
|
+
* @throws {TypeError} second argument must be a nonnegative integer
|
|
50
|
+
* @throws {TypeError} third argument must be a constructor function
|
|
51
|
+
* @returns {Function} wrapped function
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
|
|
55
|
+
* var caddf = require( '@stdlib/complex/float32/base/add' );
|
|
56
|
+
*
|
|
57
|
+
* var f = wrap( caddf, 2, Complex64 );
|
|
58
|
+
*
|
|
59
|
+
* // ...
|
|
60
|
+
*
|
|
61
|
+
* var z = f( 3.0, 4.0 );
|
|
62
|
+
* // returns <Complex64>[ 7.0, 0.0 ]
|
|
63
|
+
*/
|
|
64
|
+
function wrap( fcn, nargs, ctor ) {
|
|
65
|
+
var fcns;
|
|
66
|
+
if ( !isFunction( fcn ) ) {
|
|
67
|
+
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );
|
|
68
|
+
}
|
|
69
|
+
if ( !isNonNegativeInteger( nargs ) ) {
|
|
70
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', nargs ) );
|
|
71
|
+
}
|
|
72
|
+
if ( !isFunction( ctor ) ) {
|
|
73
|
+
throw new TypeError( format( 'invalid argument. Third argument must be a constructor function. Value: `%s`.', ctor ) );
|
|
74
|
+
}
|
|
75
|
+
fcns = [ fcn0, fcn1, fcn2, fcn3, fcn4, fcn5 ];
|
|
76
|
+
return ( nargs <= 5 ) ? fcns[ nargs ] : fcnN;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Invokes a nullary function.
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @returns {*} result
|
|
83
|
+
*/
|
|
84
|
+
function fcn0() {
|
|
85
|
+
return fcn();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Invokes a unary function accepting complex numbers.
|
|
90
|
+
*
|
|
91
|
+
* @private
|
|
92
|
+
* @param {(number|Complex)} x - input value
|
|
93
|
+
* @returns {*} result
|
|
94
|
+
*/
|
|
95
|
+
function fcn1( x ) {
|
|
96
|
+
if ( typeof x === T ) {
|
|
97
|
+
x = new ctor( x, 0.0 );
|
|
98
|
+
}
|
|
99
|
+
return fcn( x );
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Invokes a binary function accepting complex numbers.
|
|
104
|
+
*
|
|
105
|
+
* @private
|
|
106
|
+
* @param {(number|Complex)} x - input value
|
|
107
|
+
* @param {(number|Complex)} y - input value
|
|
108
|
+
* @returns {*} result
|
|
109
|
+
*/
|
|
110
|
+
function fcn2( x, y ) {
|
|
111
|
+
if ( typeof x === T ) {
|
|
112
|
+
x = new ctor( x, 0.0 );
|
|
113
|
+
}
|
|
114
|
+
if ( typeof y === T ) {
|
|
115
|
+
y = new ctor( y, 0.0 );
|
|
116
|
+
}
|
|
117
|
+
return fcn( x, y );
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Invokes a ternary function accepting complex numbers.
|
|
122
|
+
*
|
|
123
|
+
* @private
|
|
124
|
+
* @param {(number|Complex)} x - input value
|
|
125
|
+
* @param {(number|Complex)} y - input value
|
|
126
|
+
* @param {(number|Complex)} z - input value
|
|
127
|
+
* @returns {*} result
|
|
128
|
+
*/
|
|
129
|
+
function fcn3( x, y, z ) {
|
|
130
|
+
if ( typeof x === T ) {
|
|
131
|
+
x = new ctor( x, 0.0 );
|
|
132
|
+
}
|
|
133
|
+
if ( typeof y === T ) {
|
|
134
|
+
y = new ctor( y, 0.0 );
|
|
135
|
+
}
|
|
136
|
+
if ( typeof z === T ) {
|
|
137
|
+
z = new ctor( z, 0.0 );
|
|
138
|
+
}
|
|
139
|
+
return fcn( x, y, z );
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Invokes a quaternary function accepting complex numbers.
|
|
144
|
+
*
|
|
145
|
+
* @private
|
|
146
|
+
* @param {(number|Complex)} x - input value
|
|
147
|
+
* @param {(number|Complex)} y - input value
|
|
148
|
+
* @param {(number|Complex)} z - input value
|
|
149
|
+
* @param {(number|Complex)} w - input value
|
|
150
|
+
* @returns {*} result
|
|
151
|
+
*/
|
|
152
|
+
function fcn4( x, y, z, w ) {
|
|
153
|
+
if ( typeof x === T ) {
|
|
154
|
+
x = new ctor( x, 0.0 );
|
|
155
|
+
}
|
|
156
|
+
if ( typeof y === T ) {
|
|
157
|
+
y = new ctor( y, 0.0 );
|
|
158
|
+
}
|
|
159
|
+
if ( typeof z === T ) {
|
|
160
|
+
z = new ctor( z, 0.0 );
|
|
161
|
+
}
|
|
162
|
+
if ( typeof w === T ) {
|
|
163
|
+
w = new ctor( w, 0.0 );
|
|
164
|
+
}
|
|
165
|
+
return fcn( x, y, z, w );
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Invokes a quinary function accepting complex numbers.
|
|
170
|
+
*
|
|
171
|
+
* @private
|
|
172
|
+
* @param {(number|Complex)} x - input value
|
|
173
|
+
* @param {(number|Complex)} y - input value
|
|
174
|
+
* @param {(number|Complex)} z - input value
|
|
175
|
+
* @param {(number|Complex)} w - input value
|
|
176
|
+
* @param {(number|Complex)} v - input value
|
|
177
|
+
* @returns {*} result
|
|
178
|
+
*/
|
|
179
|
+
function fcn5( x, y, z, w, v ) {
|
|
180
|
+
if ( typeof x === T ) {
|
|
181
|
+
x = new ctor( x, 0.0 );
|
|
182
|
+
}
|
|
183
|
+
if ( typeof y === T ) {
|
|
184
|
+
y = new ctor( y, 0.0 );
|
|
185
|
+
}
|
|
186
|
+
if ( typeof z === T ) {
|
|
187
|
+
z = new ctor( z, 0.0 );
|
|
188
|
+
}
|
|
189
|
+
if ( typeof w === T ) {
|
|
190
|
+
w = new ctor( w, 0.0 );
|
|
191
|
+
}
|
|
192
|
+
if ( typeof v === T ) {
|
|
193
|
+
v = new ctor( v, 0.0 );
|
|
194
|
+
}
|
|
195
|
+
return fcn( x, y, z, w, v );
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Invokes a function accepting an arbitrary number of complex number input arguments.
|
|
200
|
+
*
|
|
201
|
+
* @private
|
|
202
|
+
* @param {...(number|Complex)} args - input values
|
|
203
|
+
* @returns {*} result
|
|
204
|
+
*/
|
|
205
|
+
function fcnN() {
|
|
206
|
+
var args;
|
|
207
|
+
var v;
|
|
208
|
+
var i;
|
|
209
|
+
|
|
210
|
+
args = [];
|
|
211
|
+
for ( i = 0; i < arguments.length; i++ ) {
|
|
212
|
+
v = arguments[ i ];
|
|
213
|
+
if ( typeof v === T ) {
|
|
214
|
+
v = new ctor( v, 0.0 );
|
|
215
|
+
}
|
|
216
|
+
args.push( v );
|
|
217
|
+
}
|
|
218
|
+
return fcn.apply( null, args );
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
// EXPORTS //
|
|
224
|
+
|
|
225
|
+
module.exports = wrap;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/complex/base/wrap-function",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Wrap a function accepting complex number arguments to support providing both real and complex numbers.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"directories": {
|
|
18
|
+
"benchmark": "./benchmark",
|
|
19
|
+
"doc": "./docs",
|
|
20
|
+
"example": "./examples",
|
|
21
|
+
"lib": "./lib",
|
|
22
|
+
"test": "./test"
|
|
23
|
+
},
|
|
24
|
+
"types": "./docs/types",
|
|
25
|
+
"scripts": {},
|
|
26
|
+
"homepage": "https://github.com/stdlib-js/stdlib",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git://github.com/stdlib-js/stdlib.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {},
|
|
35
|
+
"devDependencies": {},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=0.10.0",
|
|
38
|
+
"npm": ">2.7.0"
|
|
39
|
+
},
|
|
40
|
+
"os": [
|
|
41
|
+
"aix",
|
|
42
|
+
"darwin",
|
|
43
|
+
"freebsd",
|
|
44
|
+
"linux",
|
|
45
|
+
"macos",
|
|
46
|
+
"openbsd",
|
|
47
|
+
"sunos",
|
|
48
|
+
"win32",
|
|
49
|
+
"windows"
|
|
50
|
+
],
|
|
51
|
+
"keywords": [
|
|
52
|
+
"stdlib",
|
|
53
|
+
"stdtypes",
|
|
54
|
+
"types",
|
|
55
|
+
"data",
|
|
56
|
+
"structure",
|
|
57
|
+
"complex",
|
|
58
|
+
"cmplx",
|
|
59
|
+
"number",
|
|
60
|
+
"base",
|
|
61
|
+
"wrap"
|
|
62
|
+
]
|
|
63
|
+
}
|
package/cmplx/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2018 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
# Complex Numbers
|
|
22
|
+
|
|
23
|
+
> Create a complex number.
|
|
24
|
+
|
|
25
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
26
|
+
|
|
27
|
+
<section class="intro">
|
|
28
|
+
|
|
29
|
+
</section>
|
|
30
|
+
|
|
31
|
+
<!-- /.intro -->
|
|
32
|
+
|
|
33
|
+
<!-- Package usage documentation. -->
|
|
34
|
+
|
|
35
|
+
<section class="usage">
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
var complex = require( '@stdlib/complex/cmplx' );
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### complex( real, imag\[, dtype] )
|
|
44
|
+
|
|
45
|
+
Creates a complex number, where `real` and `imag` are the **real** and **imaginary** components, respectively.
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
var z = complex( 5.0, 3.0 );
|
|
49
|
+
// returns <Complex128>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
By default, the function returns a [128-bit complex number][@stdlib/complex/float64/ctor]. To specify an alternative underlying data type, set the `dtype` parameter to one of the following:
|
|
53
|
+
|
|
54
|
+
- [`'float64'`][@stdlib/complex/float64/ctor]: store **real** and **imaginary** components as double-precision floating-point numbers.
|
|
55
|
+
- [`'float32'`][@stdlib/complex/float32/ctor]: store **real** and **imaginary** components as single-precision floating-point numbers.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
var z = complex( 5.0, 3.0, 'float32' );
|
|
59
|
+
// returns <Complex64>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
</section>
|
|
63
|
+
|
|
64
|
+
<!-- /.usage -->
|
|
65
|
+
|
|
66
|
+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
67
|
+
|
|
68
|
+
<section class="notes">
|
|
69
|
+
|
|
70
|
+
</section>
|
|
71
|
+
|
|
72
|
+
<!-- /.notes -->
|
|
73
|
+
|
|
74
|
+
<!-- Package usage examples. -->
|
|
75
|
+
|
|
76
|
+
<section class="examples">
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
<!-- eslint no-undef: "error" -->
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
|
|
84
|
+
var complex = require( '@stdlib/complex/cmplx' );
|
|
85
|
+
|
|
86
|
+
var rand = discreteUniform( -50, 50 );
|
|
87
|
+
|
|
88
|
+
var z;
|
|
89
|
+
var i;
|
|
90
|
+
for ( i = 0; i < 100; i++ ) {
|
|
91
|
+
z = complex( rand(), rand(), 'float64' );
|
|
92
|
+
console.log( z.toString() );
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
</section>
|
|
97
|
+
|
|
98
|
+
<!-- /.examples -->
|
|
99
|
+
|
|
100
|
+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
101
|
+
|
|
102
|
+
<section class="references">
|
|
103
|
+
|
|
104
|
+
</section>
|
|
105
|
+
|
|
106
|
+
<!-- /.references -->
|
|
107
|
+
|
|
108
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
109
|
+
|
|
110
|
+
<section class="related">
|
|
111
|
+
|
|
112
|
+
* * *
|
|
113
|
+
|
|
114
|
+
## See Also
|
|
115
|
+
|
|
116
|
+
- <span class="package-name">[`@stdlib/complex/float64/ctor`][@stdlib/complex/float64/ctor]</span><span class="delimiter">: </span><span class="description">128-bit complex number.</span>
|
|
117
|
+
- <span class="package-name">[`@stdlib/complex/float32/ctor`][@stdlib/complex/float32/ctor]</span><span class="delimiter">: </span><span class="description">64-bit complex number.</span>
|
|
118
|
+
|
|
119
|
+
</section>
|
|
120
|
+
|
|
121
|
+
<!-- /.related -->
|
|
122
|
+
|
|
123
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
124
|
+
|
|
125
|
+
<section class="links">
|
|
126
|
+
|
|
127
|
+
<!-- <related-links> -->
|
|
128
|
+
|
|
129
|
+
[@stdlib/complex/float64/ctor]: https://github.com/stdlib-js/complex/tree/main/float64/ctor
|
|
130
|
+
|
|
131
|
+
[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/complex/tree/main/float32/ctor
|
|
132
|
+
|
|
133
|
+
<!-- </related-links> -->
|
|
134
|
+
|
|
135
|
+
</section>
|
|
136
|
+
|
|
137
|
+
<!-- /.links -->
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}( real, imag[, dtype] )
|
|
3
|
+
Creates a complex number.
|
|
4
|
+
|
|
5
|
+
The function supports the following data types:
|
|
6
|
+
|
|
7
|
+
- float64
|
|
8
|
+
- float32
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
real: number
|
|
13
|
+
Real component.
|
|
14
|
+
|
|
15
|
+
imag: number
|
|
16
|
+
Imaginary component.
|
|
17
|
+
|
|
18
|
+
dtype: string (optional)
|
|
19
|
+
Data type. Default: 'float64'.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
z: Complex
|
|
24
|
+
Complex number.
|
|
25
|
+
|
|
26
|
+
Examples
|
|
27
|
+
--------
|
|
28
|
+
> var z = {{alias}}( 5.0, 3.0, 'float64' )
|
|
29
|
+
<Complex128>
|
|
30
|
+
> z = {{alias}}( 5.0, 3.0, 'float32' )
|
|
31
|
+
<Complex64>
|
|
32
|
+
|
|
33
|
+
See Also
|
|
34
|
+
--------
|
|
35
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
import Complex128 = require( './../../../float64/ctor' );
|
|
22
|
+
import Complex64 = require( './../../../float32/ctor' );
|
|
23
|
+
|
|
24
|
+
type Complex = Complex128 | Complex64;
|
|
25
|
+
type DataType = 'float64' | 'float32';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a complex number.
|
|
29
|
+
*
|
|
30
|
+
* @param real - real component
|
|
31
|
+
* @param imag - imaginary component
|
|
32
|
+
* @param dtype - data type (default: 'float64')
|
|
33
|
+
* @returns complex number
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var z = complex( 5.0, 3.0, 'float64' );
|
|
37
|
+
* // returns <Complex128>
|
|
38
|
+
*/
|
|
39
|
+
declare function complex( real: number, imag: number, dtype?: DataType ): Complex;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// EXPORTS //
|
|
43
|
+
|
|
44
|
+
export = complex;
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
import complex = require( './index' );
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// TESTS //
|
|
23
|
+
|
|
24
|
+
// The function returns a complex number...
|
|
25
|
+
{
|
|
26
|
+
complex( 5.0, 3.0 ); // $ExpectType Complex
|
|
27
|
+
complex( 5.0, 3.0, 'float64' ); // $ExpectType Complex
|
|
28
|
+
complex( 5.0, 3.0, 'float32' ); // $ExpectType Complex
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// The compiler throws an error if the function is provided a first argument that is not a number...
|
|
32
|
+
{
|
|
33
|
+
complex( true, 3.0 ); // $ExpectError
|
|
34
|
+
complex( false, 3.0 ); // $ExpectError
|
|
35
|
+
complex( '5', 3.0 ); // $ExpectError
|
|
36
|
+
complex( [], 3.0 ); // $ExpectError
|
|
37
|
+
complex( {}, 3.0 ); // $ExpectError
|
|
38
|
+
complex( ( x: number ): number => x, 3.0 ); // $ExpectError
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The compiler throws an error if the function is provided a second argument that is not a number...
|
|
42
|
+
{
|
|
43
|
+
complex( 5.0, true ); // $ExpectError
|
|
44
|
+
complex( 5.0, false ); // $ExpectError
|
|
45
|
+
complex( 5.0, '5' ); // $ExpectError
|
|
46
|
+
complex( 5.0, [] ); // $ExpectError
|
|
47
|
+
complex( 5.0, {} ); // $ExpectError
|
|
48
|
+
complex( 5.0, ( x: number ): number => x ); // $ExpectError
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// The compiler throws an error if the function is provided a third argument that is not a recognized data type...
|
|
52
|
+
{
|
|
53
|
+
complex( 5.0, 3.0, 'abc' ); // $ExpectError
|
|
54
|
+
complex( 5.0, 3.0, 123 ); // $ExpectError
|
|
55
|
+
complex( 5.0, 3.0, true ); // $ExpectError
|
|
56
|
+
complex( 5.0, 3.0, false ); // $ExpectError
|
|
57
|
+
complex( 5.0, 3.0, [] ); // $ExpectError
|
|
58
|
+
complex( 5.0, 3.0, {} ); // $ExpectError
|
|
59
|
+
complex( 5.0, 3.0, ( x: number ): number => x ); // $ExpectError
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// The compiler throws an error if the function is provided insufficient arguments...
|
|
63
|
+
{
|
|
64
|
+
complex(); // $ExpectError
|
|
65
|
+
complex( 3 ); // $ExpectError
|
|
66
|
+
}
|
|
@@ -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
|
+
* Create a complex number.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/complex/cmplx
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var complex = require( '@stdlib/complex/cmplx' );
|
|
28
|
+
*
|
|
29
|
+
* var z = complex( 5.0, 3.0, 'float64' );
|
|
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,66 @@
|
|
|
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 ctors = require( './../../ctors' );
|
|
24
|
+
var format = require( '@stdlib/string/format' );
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// VARIABLES //
|
|
28
|
+
|
|
29
|
+
var TABLE = {
|
|
30
|
+
'float64': 'complex128',
|
|
31
|
+
'float32': 'complex64'
|
|
32
|
+
};
|
|
33
|
+
var DEFAULT_CTOR = ctors( TABLE[ 'float64' ] );
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// MAIN //
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a complex number.
|
|
40
|
+
*
|
|
41
|
+
* @param {number} real - real component
|
|
42
|
+
* @param {number} imag - imaginary component
|
|
43
|
+
* @param {string} [dtype="float64"] - data type
|
|
44
|
+
* @throws {TypeError} must provide a recognized data type
|
|
45
|
+
* @returns {Complex} complex number
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var z = complex( 5.0, 3.0, 'float64' );
|
|
49
|
+
* // returns <Complex128>
|
|
50
|
+
*/
|
|
51
|
+
function complex( real, imag, dtype ) {
|
|
52
|
+
var ctor;
|
|
53
|
+
if ( arguments.length > 2 ) {
|
|
54
|
+
ctor = ctors( TABLE[ dtype ] );
|
|
55
|
+
if ( ctor ) {
|
|
56
|
+
return new ctor( real, imag );
|
|
57
|
+
}
|
|
58
|
+
throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );
|
|
59
|
+
}
|
|
60
|
+
return new DEFAULT_CTOR( real, imag );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// EXPORTS //
|
|
65
|
+
|
|
66
|
+
module.exports = complex;
|