@stdlib/complex-float64
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -61,3 +61,3 @@ /* | ||
*/ | ||
readonly BYTES_PER_ELEMENT: number; | ||
readonly BYTES_PER_ELEMENT: 8; | ||
@@ -75,3 +75,3 @@ /** | ||
*/ | ||
readonly byteLength: number; | ||
readonly byteLength: 16; | ||
@@ -78,0 +78,0 @@ /** |
@@ -35,6 +35,6 @@ /* | ||
// tslint:disable-next-line:no-unused-expression | ||
x.BYTES_PER_ELEMENT; // $ExpectType number | ||
x.BYTES_PER_ELEMENT; // $ExpectType 8 | ||
// tslint:disable-next-line:no-unused-expression | ||
x.byteLength; // $ExpectType number | ||
x.byteLength; // $ExpectType 16 | ||
} | ||
@@ -41,0 +41,0 @@ |
@@ -35,3 +35,3 @@ /** | ||
var Complex128 = require( './complex128.js' ); | ||
var main = require( './main.js' ); | ||
@@ -41,2 +41,2 @@ | ||
module.exports = Complex128; | ||
module.exports = main; |
{ | ||
"name": "@stdlib/complex-float64", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "128-bit complex number.", | ||
@@ -41,4 +41,6 @@ "license": "Apache-2.0", | ||
"@stdlib/assert-is-number": "^0.0.x", | ||
"@stdlib/complex-float32": "^0.0.x", | ||
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", | ||
"@stdlib/utils-define-property": "^0.0.x" | ||
"@stdlib/utils-define-property": "^0.0.x", | ||
"@stdlib/utils-library-manifest": "^0.0.x" | ||
}, | ||
@@ -45,0 +47,0 @@ "devDependencies": { |
404
README.md
@@ -23,3 +23,3 @@ <!-- | ||
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url] | ||
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] --> | ||
@@ -201,15 +201,15 @@ > 128-bit complex number. | ||
console.log( 'type: %s', typeof z ); | ||
// => type: object | ||
// => 'type: object' | ||
console.log( 'str: %s', z ); | ||
// => str: 3 - 2i | ||
// => 'str: 3 - 2i' | ||
console.log( 'real: %d', z.re ); | ||
// => real: 3.0 | ||
// => 'real: 3' | ||
console.log( 'imag: %d', z.im ); | ||
// => imag: -2.0 | ||
// => 'imag: -2' | ||
console.log( 'JSON: %s', JSON.stringify( z ) ); | ||
// => JSON: {"type":"Complex128","re":3,"im":-2} | ||
// => 'JSON: {"type":"Complex128","re":3,"im":-2}' | ||
``` | ||
@@ -221,2 +221,358 @@ | ||
<!-- C interface documentation. --> | ||
* * * | ||
<section class="c"> | ||
## C APIs | ||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | ||
<section class="intro"> | ||
</section> | ||
<!-- /.intro --> | ||
<!-- C usage documentation. --> | ||
<section class="usage"> | ||
### Usage | ||
```c | ||
#include "stdlib/complex/float64.h" | ||
``` | ||
#### stdlib_complex128_t | ||
An opaque type definition for a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); | ||
``` | ||
#### stdlib_complex128_parts_t | ||
An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number. | ||
```c | ||
double real( const stdlib_complex128_t z ) { | ||
stdlib_complex128_parts_t v; | ||
// Assign a double-precision complex floating-point number: | ||
v.value = z; | ||
// Extract the real component: | ||
double re = v.parts[ 0 ]; | ||
return re; | ||
} | ||
// ... | ||
// Create a complex number: | ||
stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); | ||
// ... | ||
// Access the real component: | ||
double re = real( z ); | ||
// returns 5.0 | ||
``` | ||
The union has the following members: | ||
- **value**: `stdlib_complex128_t` double-precision complex floating-point number. | ||
- **parts**: `double[]` array having the following elements: | ||
- **0**: `double` real component. | ||
- **1**: `double` imaginary component. | ||
#### stdlib_complex128( real, imag ) | ||
Returns a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] double` real component. | ||
- **imag**: `[in] double` imaginary component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128( const double real, const double imag ); | ||
``` | ||
#### stdlib_complex128_from_float32( real ) | ||
Converts a single-precision floating-point number to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] float` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_float32( const float real ); | ||
``` | ||
#### stdlib_complex128_from_float64( real ) | ||
Converts a double-precision floating-point number to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] double` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_float64( const double real ); | ||
``` | ||
#### stdlib_complex128_from_complex64( z ) | ||
Converts a single-precision complex floating-point number to a double-precision complex floating-point number. | ||
```c | ||
#include "stdlib/complex/float32.h" | ||
stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f ); | ||
stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ); | ||
``` | ||
#### stdlib_complex128_from_complex128( z ) | ||
Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); | ||
stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ); | ||
``` | ||
#### stdlib_complex128_from_int8( real ) | ||
Converts a signed 8-bit integer to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_int8( 5 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] int8_t` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ); | ||
``` | ||
#### stdlib_complex128_from_uint8( real ) | ||
Converts an unsigned 8-bit integer to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] uint8_t` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ); | ||
``` | ||
#### stdlib_complex128_from_int16( real ) | ||
Converts a signed 16-bit integer to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_int16( 5 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] int16_t` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ); | ||
``` | ||
#### stdlib_complex128_from_uint16( real ) | ||
Converts an unsigned 16-bit integer to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] uint16_t` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ); | ||
``` | ||
#### stdlib_complex128_from_int32( real ) | ||
Converts a signed 32-bit integer to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_int32( 5 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] int32_t` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ); | ||
``` | ||
#### stdlib_complex128_from_uint32( real ) | ||
Converts an unsigned 32-bit integer to a double-precision complex floating-point number. | ||
```c | ||
stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **real**: `[in] uint32_t` real component. | ||
```c | ||
stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ); | ||
``` | ||
#### stdlib_complex128_to_complex64( z ) | ||
Converts a double-precision complex floating-point number to a single-precision complex floating-point number. | ||
```c | ||
#include "stdlib/complex/float32.h" | ||
stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 ); | ||
stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 ); | ||
``` | ||
The function accepts the following arguments: | ||
- **z**: `[in] stdlib_complex64_t` double-precision complex floating-point number. | ||
```c | ||
stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ); | ||
``` | ||
</section> | ||
<!-- /.usage --> | ||
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
<section class="notes"> | ||
</section> | ||
<!-- /.notes --> | ||
<!-- C API usage examples. --> | ||
<section class="examples"> | ||
### Examples | ||
```c | ||
#include "stdlib/complex/float64.h" | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
/** | ||
* Return the real component of a double-precision complex floating-point number. | ||
* | ||
* @param z complex number | ||
* @return real component | ||
*/ | ||
static double real( const stdlib_complex128_t z ) { | ||
stdlib_complex128_parts_t v; | ||
// Assign a double-precision complex floating-point number: | ||
v.value = z; | ||
// Extract the real component: | ||
double re = v.parts[ 0 ]; | ||
return re; | ||
} | ||
/** | ||
* Return the imaginary component of a double-precision complex floating-point number. | ||
* | ||
* @param z complex number | ||
* @return imaginary component | ||
*/ | ||
static double imag( const stdlib_complex128_t z ) { | ||
stdlib_complex128_parts_t v; | ||
// Assign a double-precision complex floating-point number: | ||
v.value = z; | ||
// Extract the imaginary component: | ||
double im = v.parts[ 1 ]; | ||
return im; | ||
} | ||
int main() { | ||
stdlib_complex128_t x[] = { | ||
stdlib_complex128( 5.0, 2.0 ), | ||
stdlib_complex128( -2.0, 1.0 ), | ||
stdlib_complex128( 0.0, -0.0 ), | ||
stdlib_complex128( 0.0/0.0, 0.0/0.0 ) | ||
}; | ||
stdlib_complex128_t v; | ||
int i; | ||
for ( i = 0; i < 4; i++ ) { | ||
v = x[ i ]; | ||
printf( "%lf + %lfi\n", real( v ), imag( v ) ); | ||
} | ||
} | ||
``` | ||
</section> | ||
<!-- /.examples --> | ||
</section> | ||
<!-- /.c --> | ||
<!-- 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. --> | ||
@@ -230,2 +586,17 @@ | ||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
<section class="related"> | ||
* * * | ||
## See Also | ||
- <span class="package-name">[`@stdlib/complex/cmplx`][@stdlib/complex/cmplx]</span><span class="delimiter">: </span><span class="description">create a complex number.</span> | ||
- <span class="package-name">[`@stdlib/complex/float32`][@stdlib/complex/float32]</span><span class="delimiter">: </span><span class="description">64-bit complex number.</span> | ||
</section> | ||
<!-- /.related --> | ||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
@@ -257,3 +628,3 @@ | ||
Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors]. | ||
Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. | ||
@@ -277,5 +648,16 @@ </section> | ||
<!-- | ||
[dependencies-image]: https://img.shields.io/david/stdlib-js/complex-float64.svg | ||
[dependencies-url]: https://david-dm.org/stdlib-js/complex-float64/main | ||
--> | ||
[umd]: https://github.com/umdjs/umd | ||
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules | ||
[deno-url]: https://github.com/stdlib-js/complex-float64/tree/deno | ||
[umd-url]: https://github.com/stdlib-js/complex-float64/tree/umd | ||
[esm-url]: https://github.com/stdlib-js/complex-float64/tree/esm | ||
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg | ||
@@ -298,4 +680,12 @@ [chat-url]: https://gitter.im/stdlib-js/stdlib/ | ||
<!-- <related-links> --> | ||
[@stdlib/complex/cmplx]: https://www.npmjs.com/package/@stdlib/complex-cmplx | ||
[@stdlib/complex/float32]: https://www.npmjs.com/package/@stdlib/complex-float32 | ||
<!-- </related-links> --> | ||
</section> | ||
<!-- /.links --> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67539
14
442
685
5
+ Added@stdlib/array-float32@0.0.6(transitive)
+ Added@stdlib/assert-has-float32array-support@0.0.8(transitive)
+ Added@stdlib/assert-has-node-buffer-support@0.0.8(transitive)
+ Added@stdlib/assert-is-array@0.0.7(transitive)
+ Added@stdlib/assert-is-boolean@0.0.8(transitive)
+ Added@stdlib/assert-is-buffer@0.0.8(transitive)
+ Added@stdlib/assert-is-float32array@0.0.8(transitive)
+ Added@stdlib/assert-is-function@0.0.8(transitive)
+ Added@stdlib/assert-is-object@0.0.8(transitive)
+ Added@stdlib/assert-is-object-like@0.0.8(transitive)
+ Added@stdlib/assert-is-plain-object@0.0.7(transitive)
+ Added@stdlib/assert-is-regexp@0.0.7(transitive)
+ Added@stdlib/assert-is-regexp-string@0.0.9(transitive)
+ Added@stdlib/assert-is-string@0.0.8(transitive)
+ Added@stdlib/assert-tools-array-function@0.0.7(transitive)
+ Added@stdlib/buffer-ctor@0.0.7(transitive)
+ Added@stdlib/buffer-from-string@0.0.8(transitive)
+ Added@stdlib/complex-float32@0.0.7(transitive)
+ Added@stdlib/constants-float64-pinf@0.0.8(transitive)
+ Added@stdlib/fs-exists@0.0.8(transitive)
+ Added@stdlib/fs-resolve-parent-path@0.0.8(transitive)
+ Added@stdlib/number-float64-base-to-float32@0.0.7(transitive)
+ Added@stdlib/process-cwd@0.0.8(transitive)
+ Added@stdlib/process-read-stdin@0.0.7(transitive)
+ Added@stdlib/regexp-eol@0.0.7(transitive)
+ Added@stdlib/regexp-extended-length-path@0.0.7(transitive)
+ Added@stdlib/regexp-function-name@0.0.7(transitive)
+ Added@stdlib/regexp-regexp@0.0.8(transitive)
+ Added@stdlib/streams-node-stdin@0.0.7(transitive)
+ Added@stdlib/string-base-format-interpolate@0.0.4(transitive)
+ Added@stdlib/string-base-format-tokenize@0.0.4(transitive)
+ Added@stdlib/string-format@0.0.3(transitive)
+ Added@stdlib/string-lowercase@0.0.9(transitive)
+ Added@stdlib/string-replace@0.0.11(transitive)
+ Added@stdlib/utils-constructor-name@0.0.8(transitive)
+ Added@stdlib/utils-convert-path@0.0.8(transitive)
+ Added@stdlib/utils-escape-regexp-string@0.0.9(transitive)
+ Added@stdlib/utils-get-prototype-of@0.0.7(transitive)
+ Added@stdlib/utils-global@0.0.7(transitive)
+ Added@stdlib/utils-library-manifest@0.0.8(transitive)
+ Added@stdlib/utils-next-tick@0.0.8(transitive)
+ Added@stdlib/utils-regexp-from-string@0.0.9(transitive)
+ Added@stdlib/utils-type-of@0.0.8(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedms@2.0.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)