Skip to content

Commit

Permalink
feat!: update namespace TypeScript declarations
Browse files Browse the repository at this point in the history
This commit reflects recent changes in the complex number namespace. Various exports have moved to sub-namespaces or have been renamed.

BREAKING CHANGE: update namespace declarations

To migrate, users should see the guidance found in the relevant commits for namespace refactoring. See issue stdlib-js#2260.

PR-URL: stdlib-js#2628
Ref: stdlib-js#2260
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com> 
Signed-off-by: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com>
  • Loading branch information
2 people authored and gunjjoshi committed Aug 21, 2024
1 parent bd2258c commit ec2e21d
Show file tree
Hide file tree
Showing 8 changed files with 660 additions and 340 deletions.
228 changes: 20 additions & 208 deletions lib/node_modules/@stdlib/complex/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,12 @@

import base = require( '@stdlib/complex/base' );
import complex = require( '@stdlib/complex/cmplx' );
import complexCtors = require( '@stdlib/complex/ctors' );
import complexDataType = require( '@stdlib/complex/dtype' );
import complexDataTypes = require( '@stdlib/complex/dtypes' );
import conjf = require( '@stdlib/complex/float32/conj' );
import Complex64 = require( '@stdlib/complex/float32/ctor' );
import imagf = require( '@stdlib/complex/float32/imag' );
import realf = require( '@stdlib/complex/float32/real' );
import reimf = require( '@stdlib/complex/float32/reim' );
import reviveComplex64 = require( '@stdlib/complex/float32/reviver' );
import conj = require( '@stdlib/complex/float64/conj' );
import Complex128 = require( '@stdlib/complex/float64/ctor' );
import imag = require( '@stdlib/complex/float64/imag' );
import real = require( '@stdlib/complex/float64/real' );
import reim = require( '@stdlib/complex/float64/reim' );
import reviveComplex128 = require( '@stdlib/complex/float64/reviver' );
import complexPromotionRules = require( '@stdlib/complex/promotion-rules' );
import ctors = require( '@stdlib/complex/ctors' );
import dtype = require( '@stdlib/complex/dtype' );
import dtypes = require( '@stdlib/complex/dtypes' );
import float32 = require( '@stdlib/complex/float32' );
import float64 = require( '@stdlib/complex/float64' );
import promotionRules = require( '@stdlib/complex/promotion-rules' );
import reviveComplex = require( '@stdlib/complex/reviver' );

/**
Expand Down Expand Up @@ -70,14 +60,14 @@ interface Namespace {
* @returns constructor or null
*
* @example
* var ctor = ns.complexCtors( 'complex128' );
* var ctor = ns.ctors( 'complex128' );
* // returns <Function>
*
* @example
* var ctor = ns.complexCtors( 'float' );
* var ctor = ns.ctors( 'float' );
* // returns null
*/
complexCtors: typeof complexCtors;
ctors: typeof ctors;

/**
* Returns the data type of a complex number.
Expand All @@ -92,212 +82,34 @@ interface Namespace {
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var dt = ns.complexDataType( new Complex64( 1.0, 2.0 ) );
* var dt = ns.dtype( new Complex64( 1.0, 2.0 ) );
* // returns 'complex64'
*
* var dt = ns.complexDataType( 'beep' );
* var dt = ns.dtype( 'beep' );
* // returns null
*/
complexDataType: typeof complexDataType;
dtype: typeof dtype;

/**
* Returns a list of complex number data types.
*
* @returns list of complex number data types
*
* @example
* var list = ns.complexDataTypes();
* var list = ns.dtypes();
* // e.g., returns [ 'complex64', 'complex128' ]
*/
complexDataTypes: typeof complexDataTypes;
dtypes: typeof dtypes;

/**
* Returns the complex conjugate of a single-precision complex floating-point number.
*
* @param z - complex number
* @returns complex conjugate
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
* var realf = require( '@stdlib/complex/float32/real' );
* var imagf = require( '@stdlib/complex/float32/imag' );
*
* var z = new Complex64( 5.0, 3.0 );
*
* var v = ns.conjf( z );
* // returns <Complex64>
*
* var re = realf( v );
* // returns 5.0
*
* var im = imagf( v );
* // returns -3.0
*/
conjf: typeof conjf;

/**
* 64-bit complex number.
*/
Complex64: typeof Complex64;

/**
* Returns the imaginary component of a single-precision complex floating-point number.
*
* @param z - complex number
* @returns imaginary component
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z = new Complex64( 5.0, 3.0 );
*
* var im = ns.imagf( z );
* // returns 3.0
*/
imagf: typeof imagf;

/**
* Returns the real component of a single-precision complex floating-point number.
*
* @param z - complex number
* @returns real component
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z = new Complex64( 5.0, 3.0 );
*
* var re = ns.realf( z );
* // returns 5.0
*/
realf: typeof realf;

/**
* Returns the real and imaginary components of a single-precision complex floating-point number.
*
* @param z - complex number
* @returns real and imaginary components
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z = new Complex64( 5.0, 3.0 );
*
* var out = ns.reimf( z );
* // returns <Float32Array>[ 5.0, 3.0 ]
*/
reimf: typeof reimf;

/**
* Revives a JSON-serialized 64-bit complex number.
*
* @param key - key
* @param value - value
* @returns value or 64-bit complex number
*
* @example
* var parseJSON = require( '@stdlib/utils/parse-json' );
*
* var str = '{"type":"Complex64","re":5,"im":3}';
*
* var z = parseJSON( str, ns.reviveComplex64 );
* // returns <Complex64>
* Single-precision complex number functions.
*/
reviveComplex64: typeof reviveComplex64;
float32: typeof float32;

/**
* Returns the complex conjugate of a double-precision complex floating-point number.
*
* @param z - complex number
* @returns complex conjugate
*
* @example
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
* var real = require( '@stdlib/complex/float64/real' );
* var imag = require( '@stdlib/complex/float64/imag' );
*
* var z = new Complex128( 5.0, 3.0 );
*
* var v = ns.conj( z );
* // returns <Complex128>
*
* var re = real( v );
* // returns 5.0
*
* var im = imag( v );
* // returns -3.0
*/
conj: typeof conj;

/**
* 128-bit complex number.
*/
Complex128: typeof Complex128;

/**
* Returns the imaginary component of a double-precision complex floating-point number.
*
* @param z - complex number
* @returns imaginary component
*
* @example
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
*
* var z = new Complex128( 5.0, 3.0 );
*
* var im = ns.imag( z );
* // returns 3.0
*/
imag: typeof imag;

/**
* Returns the real component of a double-precision complex floating-point number.
*
* @param z - complex number
* @returns real component
*
* @example
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
*
* var z = new Complex128( 5.0, 3.0 );
*
* var re = ns.real( z );
* // returns 5.0
*/
real: typeof real;

/**
* Returns the real and imaginary components of a double-precision complex floating-point number.
*
* @param z - complex number
* @returns real and imaginary components
*
* @example
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
*
* var z = new Complex128( 5.0, 3.0 );
*
* var out = ns.reim( z );
* // returns <Float64Array>[ 5.0, 3.0 ]
*/
reim: typeof reim;

/**
* Revives a JSON-serialized 128-bit complex number.
*
* @param key - key
* @param value - value
* @returns value or 128-bit complex number
*
* @example
* var parseJSON = require( '@stdlib/utils/parse-json' );
*
* var str = '{"type":"Complex128","re":5,"im":3}';
*
* var z = parseJSON( str, ns.reviveComplex128 );
* // returns <Complex128>
* Double-precision complex number functions.
*/
reviveComplex128: typeof reviveComplex128;
float64: typeof float64;

/**
* Returns a type promotion table displaying complex number data types with the smallest size and closest "kind" to which data types can be safely cast.
Expand All @@ -307,10 +119,10 @@ interface Namespace {
* @returns promotion rule table
*
* @example
* var table = ns.complexPromotionRules();
* var table = ns.promotionRules();
* // returns {...}
*/
complexPromotionRules: typeof complexPromotionRules;
promotionRules: typeof promotionRules;

/**
* Revives a JSON-serialized complex number.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,100 @@
/* eslint-disable max-lines */

import isEqual = require( '@stdlib/complex/float32/base/assert/is-equal' );
import isNotEqual = require( '@stdlib/complex/float32/base/assert/is-not-equal' );
import isSameValue = require( '@stdlib/complex/float32/base/assert/is-same-value' );
import isSameValueZero = require( '@stdlib/complex/float32/base/assert/is-same-value-zero' );

/**
* Interface describing the namespace.
* Interface describing the `assert` namespace.
*/
interface Namespace {
/**
* TODO
* Tests whether two single-precision complex floating-point numbers are equal.
*
* @param z1 - first complex number
* @param z2 - second complex number
* @returns boolean indicating if both complex numbers are equal
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z1 = new Complex64( 5.0, 3.0 );
* var z2 = new Complex64( 5.0, 3.0 );
*
* var v = ns.isEqual( z1, z2 );
* // returns true
*/
isEqual: typeof isEqual;

/**
* Tests whether two single-precision complex floating-point numbers are not equal.
*
* @param z1 - first complex number
* @param z2 - second complex number
* @returns boolean indicating if both complex numbers are not equal
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z1 = new Complex64( 5.0, 3.0 );
* var z2 = new Complex64( 5.0, -3.0 );
*
* var v = ns.isNotEqual( z1, z2 );
* // returns true
*/
isNotEqual: typeof isNotEqual;

/**
* Tests whether two single-precision complex floating-point numbers are the same value.
*
* ## Notes
*
* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.
* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.
*
* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12
*
* @param z1 - first complex number
* @param z2 - second complex number
* @returns boolean indicating if both complex numbers are the same value
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z1 = new Complex64( 5.0, 3.0 );
* var z2 = new Complex64( 5.0, 3.0 );
*
* var v = ns.isSameValue( z1, z2 );
* // returns true
*/
isSameValue: typeof isSameValue;

/**
* Tests whether two single-precision complex floating-point numbers are the same value.
*
* ## Notes
*
* - In contrast to the strict equality operator `===`, `NaNs` are treated as the same value.
*
* @param z1 - first complex number
* @param z2 - second complex number
* @returns boolean indicating if both complex numbers are the same value
*
* @example
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var z1 = new Complex64( 5.0, 3.0 );
* var z2 = new Complex64( 5.0, 3.0 );
*
* var v = ns.isSameValueZero( z1, z2 );
* // returns true
*/
isSameValueZero: typeof isSameValueZero;
}

/**
* Base (i.e., lower-level) single-precision complex floating-point number assertion functions.
* Base (i.e., lower-level) single-precision complex number assertion functions.
*/
declare var ns: Namespace;

Expand Down
Loading

0 comments on commit ec2e21d

Please sign in to comment.