Socket
Socket
Sign inDemoInstall

@stdlib/types

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/types - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

1963

index.d.ts

@@ -0,1 +1,3 @@

/* tslint:disable:max-file-line-count */
/*

@@ -27,3 +29,3 @@ * @license Apache-2.0

*
* const x: array.ArrayLike = [ 1, 2, 3 ];
* const x: array.ArrayLike<number> = [ 1, 2, 3 ];
*

@@ -33,6 +35,53 @@ * @example

*
* const x: ArrayLike = [ 1, 2, 3 ];
* const x: ArrayLike<number> = [ 1, 2, 3 ];
*/
declare module '@stdlib/types/array' {
import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/object';
/**
* Data type.
*/
type DataType = RealOrComplexDataType | 'generic';
/**
* Data type for real-valued typed arrays.
*/
type RealDataType = FloatDataType | IntegerDataType;
/**
* Data type for floating-point typed arrays.
*/
type FloatDataType = 'float64' | 'float32';
/**
* Data type for integer typed arrays.
*/
type IntegerDataType = SignedIntegerDataType | UnsignedIntegerDataType;
/**
* Data type for signed integer typed arrays.
*/
type SignedIntegerDataType = 'int32' | 'int16' | 'int8';
/**
* Data type for unsigned integer typed arrays.
*/
type UnsignedIntegerDataType = 'uint32' | 'uint16' | 'uint8' | 'uint8c';
/**
* Data type for complex number typed arrays.
*/
type ComplexDataType = 'complex64' | 'complex128';
/**
* Data type for floating-point real or complex typed arrays.
*/
type FloatOrComplexDataType = FloatDataType | ComplexDataType;
/**
* Data type for real-valued or complex number typed arrays.
*/
type RealOrComplexDataType = RealDataType | ComplexDataType;
/**
* An array-like value.

@@ -58,2 +107,45 @@ *

/**
* An array-like value which exposes accessors for getting and setting array elements.
*
* @example
* const xbuf: Array = [ 1, 2, 3 ];
* const x: AccessorArrayLike<number> = {
* 'length': 3,
* 'data': xbuf,
* 'get': ( i: number ): number => xbuf[ i ],
* 'set': ( value: number, i?: number ): void => {
* xbuf[ i || 0 ] = value;
* return;
* }
* };
*/
interface AccessorArrayLike<T> {
/**
* Properties.
*/
[key: string]: any;
/**
* Number of elements.
*/
length: number;
/**
* Returns an array element.
*
* @param i - element index
* @returns array element
*/
get( i: number ): T | void;
/**
* Sets an array element.
*
* @param value - value(s)
* @param i - element index at which to start writing values (default: 0)
*/
set( value: T, i?: number ): void;
}
/**
* A numeric array.

@@ -68,4 +160,26 @@ *

/**
* Any array.
*
* @example
* const x: AnyArray = [ 1, 2, 3 ];
* const y: AnyArray = new Float64Array( 10 );
*/
type AnyArray = Array<any> | RealOrComplexTypedArray;
/**
* An array or typed array.
*
* @example
* const x: ArrayOrTypedArray = [ 1, 2, 3 ];
* const y: ArrayOrTypedArray = new Float64Array( 10 );
*/
type ArrayOrTypedArray = Array<any> | TypedArray;
/**
* A typed array.
*
* ## Notes
*
* - This is a strict definition of a typed array. Namely, the type is limited to only built-in typed arrays.
*
* @example

@@ -75,5 +189,14 @@ * const x: TypedArray = new Float64Array( 10 );

*/
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; // tslint:disable-line:max-line-length
type TypedArray = FloatTypedArray | IntegerTypedArray;
/**
* A real-valued typed array.
*
* @example
* const x: RealTypedArray = new Float64Array( 10 );
* const y: RealTypedArray = new Uint32Array( 10 );
*/
type RealTypedArray = TypedArray;
/**
* An integer typed array.

@@ -85,3 +208,211 @@ *

*/
type IntegerTypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array; // tslint:disable-line:max-line-length
type IntegerTypedArray = SignedIntegerTypedArray | UnsignedIntegerTypedArray; // tslint:disable-line:max-line-length
/**
* A signed integer typed array.
*
* @example
* const x: SignedIntegerTypedArray = new Int32Array( 10 );
*/
type SignedIntegerTypedArray = Int8Array | Int16Array | Int32Array;
/**
* An unsigned integer typed array.
*
* @example
* const x: UnsignedIntegerTypedArray = new Uint32Array( 10 );
*/
type UnsignedIntegerTypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array; // tslint:disable-line:max-line-length
/**
* A floating-point typed array.
*
* @example
* const x: FloatTypedArray = new Float64Array( 10 );
* const y: FloatTypedArray = new Float32Array( 10 );
*/
type FloatTypedArray = Float32Array | Float64Array;
/**
* A complex number typed array.
*
* @example
* const x: ComplexTypedArray = new Complex64Array( 10 );
*/
type ComplexTypedArray = Complex64Array | Complex128Array;
/**
* A real or complex array.
*
* @example
* const x: RealOrComplexArray = new Float64Array( 10 );
* const y: RealOrComplexArray = [ 1, 2, 3 ];
*/
type RealOrComplexArray = NumericArray | ComplexTypedArray;
/**
* A floating-point real or complex typed array.
*
* @example
* const x: FloatOrComplexTypedArray = new Float64Array( 10 );
*/
type FloatOrComplexTypedArray = FloatTypedArray | ComplexTypedArray;
/**
* A real or complex typed array.
*
* @example
* const x: RealOrComplexTypedArray = new Float64Array( 10 );
*/
type RealOrComplexTypedArray = RealTypedArray | ComplexTypedArray;
/**
* A complex number array-like value.
*
* @example
* const buf = new Float64Array( 8 );
*
* const z: ComplexArrayLike = {
* 'byteLength': 64,
* 'byteOffset': 0,
* 'BYTES_PER_ELEMENT': 8,
* 'length': 8
* 'get': ( i: number ): obj.ComplexLike => {
* return {
* 're': i * 10,
* 'im': i * 10
* };
* },
* 'set': ( value: obj.ComplexLike, i?: number ) => {
* i = ( i ) ? i : 0;
* buf[ i ] = value.re;
* buf[ i + 1 ] = value.im;
* }
* };
*/
interface ComplexArrayLike extends AccessorArrayLike<ComplexLike> {
/**
* Length (in bytes) of the array.
*/
byteLength: number;
/**
* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.
*/
byteOffset: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* Number of array elements.
*/
length: number;
/**
* Returns an array element.
*
* @param i - element index
* @returns array element
*/
get( i: number ): ComplexLike | void;
/**
* Sets an array element.
*
* @param value - value(s)
* @param i - element index at which to start writing values (default: 0)
*/
set( value: ArrayLike<number | ComplexLike> | ComplexArrayLike | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length
}
/**
* 64-bit complex number array.
*
* @example
* const buf = new Float32Array( 8 );
*
* const z: Complex64Array = {
* 'byteLength': 32,
* 'byteOffset': 0,
* 'BYTES_PER_ELEMENT': 4,
* 'length': 8
* 'get': ( i: number ): obj.Complex64 => {
* return {
* 're': i * 10,
* 'im': i * 10,
* 'byteLength': 8,
* 'BYTES_PER_ELEMENT': 4
* };
* },
* 'set': ( value: obj.ComplexLike, i?: number ) => {
* i = ( i ) ? i : 0;
* buf[ i ] = value.re;
* buf[ i + 1 ] = value.im;
* }
* };
*/
interface Complex64Array extends ComplexArrayLike {
/**
* Returns an array element.
*
* @param i - element index
* @returns array element
*/
get( i: number ): Complex64 | void;
/**
* Sets an array element.
*
* @param value - value(s)
* @param i - element index at which to start writing values (default: 0)
*/
set( value: ArrayLike<number | ComplexLike> | Complex64Array | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length
}
/**
* 128-bit complex number array.
*
* @example
* const buf = new Float64Array( 8 );
*
* const z: Complex128Array = {
* 'byteLength': 64,
* 'byteOffset': 0,
* 'BYTES_PER_ELEMENT': 8,
* 'length': 8
* 'get': ( i: number ): obj.Complex128 => {
* return {
* 're': i * 10,
* 'im': i * 10,
* 'byteLength': 16,
* 'BYTES_PER_ELEMENT': 8
* };
* },
* 'set': ( value: obj.ComplexLike, i?: number ) => {
* i = ( i ) ? i : 0;
* buf[ i ] = value.re;
* buf[ i + 1 ] = value.im;
* }
* };
*/
interface Complex128Array extends ComplexArrayLike {
/**
* Returns an array element.
*
* @param i - element index
* @returns array element
*/
get( i: number ): Complex128 | void;
/**
* Sets an array element.
*
* @param value - value(s)
* @param i - element index at which to start writing values (default: 0)
*/
set( value: ArrayLike<number | ComplexLike> | Complex128Array | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length
}
}

@@ -170,2 +501,66 @@

}
/**
* Interface describing an iterator protocol-compliant object.
*
* @example
* const it: TypedIterator<number> = {
* 'next': () => { return { 'value': 0, 'done': false }; }
* };
*/
interface TypedIterator<T> {
/**
* Returns an iterator protocol-compliant object containing the next iterated value (if one exists) and a boolean flag indicating whether the iterator is finished.
*
* @returns iterator protocol-compliant object
*/
next(): TypedIteratorResult<T>;
/**
* Finishes an iterator.
*
* @param value - value to return
* @returns iterator protocol-compliant object
*/
return?( value?: T ): TypedIteratorResult<T>;
}
/**
* Interface describing an iterable iterator protocol-compliant object.
*
* @example
* const it: IterableIterator = {
* 'next': () => { return { 'value': 0, 'done': false }; },
* [Symbol.iterator]: () => { return this; }
* };
*/
interface TypedIterableIterator<T> extends TypedIterator<T> {
/**
* Returns a new iterable iterator.
*
* @returns iterable iterator
*/
[Symbol.iterator](): TypedIterableIterator<T>;
}
/**
* Interface describing an iterator protocol-compliant results object.
*
* @example
* const o: TypedIteratorResult<number> = {
* 'value': 3.14,
* 'done': false
* };
*/
interface TypedIteratorResult<T> {
/**
* Iterated value (if one exists).
*/
value?: T;
/**
* Boolean flag indicating whether an iterator is finished.
*/
done: boolean;
}
}

@@ -231,3 +626,4 @@

declare module '@stdlib/types/ndarray' {
import { ArrayLike } from '@stdlib/types/array';
import { ArrayLike, AccessorArrayLike, Complex128Array, Complex64Array, RealOrComplexTypedArray, FloatOrComplexTypedArray, RealTypedArray, ComplexTypedArray, IntegerTypedArray, FloatTypedArray, SignedIntegerTypedArray, UnsignedIntegerTypedArray } from '@stdlib/types/array'; // tslint:disable-line:max-line-length
import { ComplexLike, Complex128, Complex64 } from '@stdlib/types/object';

@@ -237,5 +633,45 @@ /**

*/
type DataType = 'float64' | 'float32' | 'int32' | 'int16' | 'int8' | 'uint32' | 'uint16' | 'uint8' | 'uint8c' | 'complex64' | 'complex128' | 'binary' | 'generic'; // tslint:disable-line:max-line-length
type DataType = RealOrComplexDataType | 'binary' | 'generic';
/**
* Data type for real-valued ndarrays.
*/
type RealDataType = FloatDataType | IntegerDataType;
/**
* Data type for floating-point ndarrays.
*/
type FloatDataType = 'float64' | 'float32';
/**
* Data type for integer ndarrays.
*/
type IntegerDataType = SignedIntegerDataType | UnsignedIntegerDataType;
/**
* Data type for signed integer ndarrays.
*/
type SignedIntegerDataType = 'int32' | 'int16' | 'int8';
/**
* Data type for unsigned integer ndarrays.
*/
type UnsignedIntegerDataType = 'uint32' | 'uint16' | 'uint8' | 'uint8c';
/**
* Data type for complex number ndarrays.
*/
type ComplexDataType = 'complex64' | 'complex128';
/**
* Data type for floating-point real or complex ndarrays.
*/
type FloatOrComplexDataType = FloatDataType | ComplexDataType;
/**
* Data type for real-valued or complex number ndarrays.
*/
type RealOrComplexDataType = RealDataType | ComplexDataType;
/**
* Array order.

@@ -263,2 +699,20 @@ *

/**
* Array shape.
*
* ## Notes
*
* - Each element of the array shape (i.e., dimension size) should be a nonnegative integer.
*/
type Shape = ArrayLike<number>;
/**
* Array strides.
*
* ## Notes
*
* - Each stride (i.e., index increment along a respective dimension) should be an integer.
*/
type Strides = ArrayLike<number>;
/**
* Interface describing an ndarray.

@@ -305,3 +759,3 @@ *

*/
data: ArrayLike<any>;
data: ArrayLike<any> | AccessorArrayLike<any>;

@@ -314,3 +768,3 @@ /**

/**
* Information regarding the memory layout of the array.
* Flags and other meta information (e.g., memory layout of the array).
*/

@@ -327,2 +781,7 @@ flags: {

COLUMN_MAJOR_CONTIGUOUS: boolean;
/**
* Boolean indicating if an array is read-only.
*/
READONLY?: boolean;
};

@@ -357,3 +816,3 @@

*/
shape: ArrayLike<number>;
shape: Shape;

@@ -363,3 +822,3 @@ /**

*/
strides: ArrayLike<number>;
strides: Strides;

@@ -390,2 +849,1435 @@ /**

}
/**
* Interface describing an ndarray having a generic data type.
*
* @example
* const arr: genericndarray = {
* 'byteLength': null,
* 'BYTES_PER_ELEMENT': null,
* 'data': [ 1, 2, 3 ],
* 'dtype': 'generic',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface genericndarray extends ndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: null;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: null;
/**
* Underlying data type.
*/
dtype: 'generic';
/**
* A reference to the underlying data buffer.
*/
data: ArrayLike<any>;
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): any;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<any> ): genericndarray;
}
/**
* Interface describing an ndarray having a homogeneous data type.
*
* @example
* const arr: typedndarray<number> = {
* 'byteLength': null,
* 'BYTES_PER_ELEMENT': null,
* 'data': [ 1, 2, 3 ],
* 'dtype': 'generic',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface typedndarray<T> extends ndarray { // tslint:disable-line:class-name
/**
* A reference to the underlying data buffer.
*/
data: ArrayLike<T>;
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): T;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number | T> ): typedndarray<T>;
}
/**
* Interface describing an ndarray having a floating-point data type.
*
* @example
* const arr: floatndarray = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface floatndarray extends typedndarray<number> { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: FloatTypedArray;
/**
* Underlying data type.
*/
dtype: FloatDataType;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): floatndarray;
}
/**
* Interface describing an ndarray having a double-precision floating-point data type.
*
* @example
* const arr: float64ndarray = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface float64ndarray extends floatndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 8;
/**
* A reference to the underlying data buffer.
*/
data: Float64Array;
/**
* Underlying data type.
*/
dtype: 'float64';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): float64ndarray;
}
/**
* Interface describing an ndarray having a single-precision floating-point data type.
*
* @example
* const arr: float32ndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Float32Array( [ 1, 2, 3 ] ),
* 'dtype': 'float32',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface float32ndarray extends floatndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 4;
/**
* A reference to the underlying data buffer.
*/
data: Float32Array;
/**
* Underlying data type.
*/
dtype: 'float32';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): float32ndarray;
}
/**
* Interface describing an ndarray having an integer data type.
*
* @example
* const arr: integerndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Int32Array( [ 1, 2, 3 ] ),
* 'dtype': 'int32',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface integerndarray extends typedndarray<number> { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: IntegerTypedArray;
/**
* Underlying data type.
*/
dtype: IntegerDataType;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): integerndarray;
}
/**
* Interface describing an ndarray having a signed integer data type.
*
* @example
* const arr: signedintegerndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Int32Array( [ 1, 2, 3 ] ),
* 'dtype': 'int32',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface signedintegerndarray extends typedndarray<number> { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: SignedIntegerTypedArray;
/**
* Underlying data type.
*/
dtype: SignedIntegerDataType;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): signedintegerndarray;
}
/**
* Interface describing an ndarray having a signed 32-bit integer data type.
*
* @example
* const arr: int32ndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Int32Array( [ 1, 2, 3 ] ),
* 'dtype': 'int32',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface int32ndarray extends signedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 4;
/**
* A reference to the underlying data buffer.
*/
data: Int32Array;
/**
* Underlying data type.
*/
dtype: 'int32';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): int32ndarray;
}
/**
* Interface describing an ndarray having a signed 16-bit integer data type.
*
* @example
* const arr: int16ndarray = {
* 'byteLength': 6,
* 'BYTES_PER_ELEMENT': 2,
* 'data': new Int16Array( [ 1, 2, 3 ] ),
* 'dtype': 'int16',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface int16ndarray extends signedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 2;
/**
* A reference to the underlying data buffer.
*/
data: Int16Array;
/**
* Underlying data type.
*/
dtype: 'int16';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): int16ndarray;
}
/**
* Interface describing an ndarray having a signed 8-bit integer data type.
*
* @example
* const arr: int8ndarray = {
* 'byteLength': 3,
* 'BYTES_PER_ELEMENT': 1,
* 'data': new Int8Array( [ 1, 2, 3 ] ),
* 'dtype': 'int8',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface int8ndarray extends signedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 1;
/**
* A reference to the underlying data buffer.
*/
data: Int8Array;
/**
* Underlying data type.
*/
dtype: 'int8';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): int8ndarray;
}
/**
* Interface describing an ndarray having an unsigned integer data type.
*
* @example
* const arr: unsignedintegerndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Uint32Array( [ 1, 2, 3 ] ),
* 'dtype': 'uint32',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface unsignedintegerndarray extends typedndarray<number> { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: UnsignedIntegerTypedArray;
/**
* Underlying data type.
*/
dtype: UnsignedIntegerDataType;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): unsignedintegerndarray;
}
/**
* Interface describing an ndarray having an unsigned 32-bit integer data type.
*
* @example
* const arr: uint32ndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Uint32Array( [ 1, 2, 3 ] ),
* 'dtype': 'uint32',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface uint32ndarray extends unsignedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 4;
/**
* A reference to the underlying data buffer.
*/
data: Uint32Array;
/**
* Underlying data type.
*/
dtype: 'uint32';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): uint32ndarray;
}
/**
* Interface describing an ndarray having an unsigned 16-bit integer data type.
*
* @example
* const arr: uint16ndarray = {
* 'byteLength': 6,
* 'BYTES_PER_ELEMENT': 2,
* 'data': new Uint16Array( [ 1, 2, 3 ] ),
* 'dtype': 'uint16',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface uint16ndarray extends unsignedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 2;
/**
* A reference to the underlying data buffer.
*/
data: Uint16Array;
/**
* Underlying data type.
*/
dtype: 'uint16';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): uint16ndarray;
}
/**
* Interface describing an ndarray having an unsigned 8-bit integer data type.
*
* @example
* const arr: uint8ndarray = {
* 'byteLength': 3,
* 'BYTES_PER_ELEMENT': 1,
* 'data': new Uint8Array( [ 1, 2, 3 ] ),
* 'dtype': 'uint8',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface uint8ndarray extends unsignedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 1;
/**
* A reference to the underlying data buffer.
*/
data: Uint8Array;
/**
* Underlying data type.
*/
dtype: 'uint8';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): uint8ndarray;
}
/**
* Interface describing an ndarray having a clamped unsigned 8-bit integer data type.
*
* @example
* const arr: uint8cndarray = {
* 'byteLength': 12,
* 'BYTES_PER_ELEMENT': 4,
* 'data': new Uint8ClampedArray( [ 1, 2, 3 ] ),
* 'dtype': 'uint8c',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface uint8cndarray extends unsignedintegerndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 1;
/**
* A reference to the underlying data buffer.
*/
data: Uint8ClampedArray;
/**
* Underlying data type.
*/
dtype: 'uint8c';
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): uint8cndarray;
}
/**
* Interface describing an ndarray having a real-valued data type.
*
* @example
* const arr: realndarray = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface realndarray extends typedndarray<number> { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: RealTypedArray;
/**
* Underlying data type.
*/
dtype: RealDataType;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number> ): realndarray;
}
/**
* Interface describing an ndarray having a real or complex number data type.
*
* @example
* const arr: realcomplexndarray = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface realcomplexndarray extends ndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: RealOrComplexTypedArray;
/**
* Underlying data type.
*/
dtype: RealOrComplexDataType;
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): number | ComplexLike | void;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number | ComplexLike> ): realcomplexndarray;
}
/**
* Interface describing an ndarray having a floating-point real or complex number data type.
*
* @example
* const arr: floatcomplexndarray = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface floatcomplexndarray extends ndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: FloatOrComplexTypedArray;
/**
* Underlying data type.
*/
dtype: FloatOrComplexDataType;
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): number | ComplexLike | void;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number | ComplexLike> ): floatcomplexndarray;
}
/**
* Interface describing an ndarray having a complex number data type.
*
* @example
* const arr: complexndarray = {
* 'byteLength': 48,
* 'BYTES_PER_ELEMENT': 16,
* 'data': new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ),
* 'dtype': 'complex128',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return new Complex128( this.data[ i*2 ], this.data[ (i*2)+1 ] );
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface complexndarray extends ndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of the array.
*/
byteLength: number;
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: number;
/**
* A reference to the underlying data buffer.
*/
data: ComplexTypedArray;
/**
* Underlying data type.
*/
dtype: ComplexDataType;
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): ComplexLike | void;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number | ComplexLike> ): complexndarray;
}
/**
* Interface describing an ndarray having a double-precision complex floating-point data type.
*
* @example
* const arr: complex128ndarray = {
* 'byteLength': 48,
* 'BYTES_PER_ELEMENT': 16,
* 'data': new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ),
* 'dtype': 'complex128',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return new Complex128( this.data[ i*2 ], this.data[ (i*2)+1 ] );
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface complex128ndarray extends complexndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 16;
/**
* A reference to the underlying data buffer.
*/
data: Complex128Array;
/**
* Underlying data type.
*/
dtype: 'complex128';
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): Complex128 | void;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number | ComplexLike> ): complex128ndarray;
}
/**
* Interface describing an ndarray having a single-precision complex floating-point data type.
*
* @example
* const arr: complex64ndarray = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ),
* 'dtype': 'complex64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return new Complex64( this.data[ i*2 ], this.data[ (i*2)+1 ] );
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface complex64ndarray extends complexndarray { // tslint:disable-line:class-name
/**
* Size (in bytes) of each array element.
*/
BYTES_PER_ELEMENT: 8;
/**
* A reference to the underlying data buffer.
*/
data: Complex64Array;
/**
* Underlying data type.
*/
dtype: 'complex64';
/**
* Returns an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts
* @returns array element
*/
get( ...args: Array<number> ): Complex64 | void;
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param args - subscripts and value to set
* @returns ndarray instance
*/
set( ...args: Array<number | ComplexLike> ): complex64ndarray;
}
/**
* Interface describing a one-dimensional ndarray having a homogeneous data type.
*
* @example
* const arr: Vector<number> = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 1,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 3 ],
* 'strides': [ 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface Vector<T> extends typedndarray<T> {
/**
* Number of dimensions.
*/
ndims: 1;
/**
* Array shape.
*/
shape: [ number ]; // tslint:disable-line:no-single-element-tuple-type
/**
* Array strides.
*/
strides: [ number ]; // tslint:disable-line:no-single-element-tuple-type
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param i - element index
* @param value - value to set
* @returns ndarray instance
*/
set( i: number, value: T ): Vector<T>;
}
/**
* Interface describing a two-dimensional ndarray having a homogeneous data type.
*
* @example
* const arr: Matrix<number> = {
* 'byteLength': 24,
* 'BYTES_PER_ELEMENT': 8,
* 'data': new Float64Array( [ 1, 2, 3 ] ),
* 'dtype': 'float64',
* 'flags': {
* 'ROW_MAJOR_CONTIGUOUS': true,
* 'COLUMN_MAJOR_CONTIGUOUS': false
* },
* 'length': 3,
* 'ndims': 2,
* 'offset': 0,
* 'order': 'row-major',
* 'shape': [ 1, 3 ],
* 'strides': [ 3, 1 ],
* 'get': function get( i ) {
* return this.data[ i ];
* },
* 'set': function set( i, v ) {
* this.data[ i ] = v;
* return this;
* }
* };
*/
interface Matrix<T> extends typedndarray<T> {
/**
* Number of dimensions.
*/
ndims: 2;
/**
* Array shape.
*/
shape: [ number, number ];
/**
* Array strides.
*/
strides: [ number, number ];
/**
* Sets an array element specified according to provided subscripts.
*
* ## Notes
*
* - The number of provided subscripts should equal the number of dimensions.
*
* @param i - index along first dimension
* @param j - index along second dimension
* @param value - value to set
* @returns ndarray instance
*/
set( i: number, j: number, value: T ): Matrix<T>;
}
}

@@ -526,2 +2418,7 @@

/**
* Complex number data type.
*/
type ComplexDataType = 'complex64' | 'complex128';
/**
* A complex number-like object.

@@ -543,2 +2440,48 @@ *

}
/**
* A 64-bit complex number.
*
* @example
* const x: Complex64 = {
* 're': 5.0,
* 'im': 3.0,
* 'byteLength': 8,
* 'BYTES_PER_ELEMENT': 4
* };
*/
interface Complex64 extends ComplexLike {
/**
* Size (in bytes) of the complex number.
*/
byteLength: 8;
/**
* Size (in bytes) of each component.
*/
BYTES_PER_ELEMENT: 4;
}
/**
* A 128-bit complex number.
*
* @example
* const x: Complex128 = {
* 're': 5.0,
* 'im': 3.0,
* 'byteLength': 16,
* 'BYTES_PER_ELEMENT': 8
* };
*/
interface Complex128 extends ComplexLike {
/**
* Size (in bytes) of the complex number.
*/
byteLength: 16;
/**
* Size (in bytes) of each component.
*/
BYTES_PER_ELEMENT: 8;
}
}

@@ -545,0 +2488,0 @@

2

package.json
{
"name": "@stdlib/types",
"version": "0.0.13",
"version": "0.0.14",
"description": "stdlib TypeScript type declarations.",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -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] -->

@@ -57,3 +57,3 @@ > TypeScript type declarations for stdlib.

function sum( x: ArrayLike ): number {
function sum( x: ArrayLike<number> ): number {
let s = 0.0;

@@ -78,8 +78,6 @@ for ( let i = 0; i < x.length; i++ ) {

let v = iter.next();
if ( typeof v.value === 'number' ) {
s += v.value;
}
if ( v.done ) {
break;
}
s += v.value;
}

@@ -135,2 +133,10 @@ return s;

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
<section class="related">
</section>
<!-- /.related -->
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

@@ -162,3 +168,3 @@

Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].

@@ -182,5 +188,16 @@ </section>

<!--
[dependencies-image]: https://img.shields.io/david/stdlib-js/types.svg
[dependencies-url]: https://david-dm.org/stdlib-js/types/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/types/tree/deno
[umd-url]: https://github.com/stdlib-js/types/tree/umd
[esm-url]: https://github.com/stdlib-js/types/tree/esm
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg

@@ -187,0 +204,0 @@ [chat-url]: https://gitter.im/stdlib-js/stdlib/

@@ -104,3 +104,88 @@ /*

/**
* Returns a complex number array-like object.
*
* @returns complex number array-like object
*/
function cmplxArray(): array.ComplexArrayLike {
const buf: array.TypedArray = new Float64Array( 8 );
const obj: array.ComplexArrayLike = {
'byteLength': 64,
'byteOffset': 0,
'BYTES_PER_ELEMENT': 8,
'length': 8,
'get': ( i: number ): obj.ComplexLike => {
return {
're': i * 10,
'im': i * 10
};
},
'set': ( value: obj.ComplexLike, i?: number ) => {
i = ( i ) ? i : 0;
buf[ i ] = value.re;
buf[ i + 1 ] = value.im;
}
};
return obj;
}
/**
* Returns a 64-bit complex number array.
*
* @returns 64-bit complex number array
*/
function cmplx64Array(): array.Complex64Array {
const buf: array.TypedArray = new Float64Array( 8 );
const obj: array.Complex64Array = {
'byteLength': 64,
'byteOffset': 0,
'BYTES_PER_ELEMENT': 8,
'length': 8,
'get': ( i: number ): obj.Complex64 => {
return {
're': i * 10,
'im': i * 10,
'byteLength': 8,
'BYTES_PER_ELEMENT': 4
};
},
'set': ( value: obj.Complex64, i?: number ) => {
i = ( i ) ? i : 0;
buf[ i ] = value.re;
buf[ i + 1 ] = value.im;
}
};
return obj;
}
/**
* Returns a 128-bit complex number array.
*
* @returns 128-bit complex number array
*/
function cmplx128Array(): array.Complex128Array {
const buf: array.TypedArray = new Float64Array( 16 );
const obj: array.Complex128Array = {
'byteLength': 128,
'byteOffset': 0,
'BYTES_PER_ELEMENT': 16,
'length': 8,
'get': ( i: number ): obj.Complex128 => {
return {
're': i * 10,
'im': i * 10,
'byteLength': 16,
'BYTES_PER_ELEMENT': 8
};
},
'set': ( value: obj.Complex128, i?: number ) => {
i = ( i ) ? i : 0;
buf[ i ] = value.re;
buf[ i + 1 ] = value.im;
}
};
return obj;
}
// TESTS //

@@ -139,2 +224,86 @@

}
const zz: array.ComplexArrayLike = cmplxArray();
if ( zz.byteOffset !== 0 ) {
throw new Error( 'something went wrong' );
}
const z64: array.Complex64Array = cmplx64Array();
if ( z64.byteOffset !== 0 ) {
throw new Error( 'something went wrong' );
}
const z128: array.Complex128Array = cmplx128Array();
if ( z128.byteOffset !== 0 ) {
throw new Error( 'something went wrong' );
}
const zzz: array.ComplexTypedArray = cmplx64Array();
if ( zzz.byteOffset !== 0 ) {
throw new Error( 'something went wrong' );
}
const v1: array.ArrayOrTypedArray = new Float64Array( 10 );
if ( v1[ 0 ] !== 0.0 ) {
throw new Error( 'something went wrong' );
}
const v2: array.FloatTypedArray = new Float64Array( 10 );
if ( v2[ 0 ] !== 0.0 ) {
throw new Error( 'something went wrong' );
}
const v3: array.RealOrComplexArray = new Float64Array( 10 );
if ( v3[ 0 ] !== 0.0 ) {
throw new Error( 'something went wrong' );
}
const v4: array.RealOrComplexTypedArray = new Float64Array( 10 );
if ( v4[ 0 ] !== 0.0 ) {
throw new Error( 'something went wrong' );
}
const v5buf: array.ArrayLike<number> = new Float64Array( 10 );
const v5: array.AccessorArrayLike<number> = {
'length': 10,
'data': v5buf,
'get': ( i: number ): number => v5buf[ i ],
'set': ( value: number, i?: number ): void => {
v5buf[ i || 0 ] = value;
return;
}
};
if ( v5.length !== 10 ) {
throw new Error( 'something went wrong' );
}
const v6: array.IntegerTypedArray = new Int32Array( 10 );
if ( v6[ 0 ] !== 0 ) {
throw new Error( 'something went wrong' );
}
const v7: array.SignedIntegerTypedArray = new Int32Array( 10 );
if ( v7[ 0 ] !== 0 ) {
throw new Error( 'something went wrong' );
}
const v8: array.UnsignedIntegerTypedArray = new Uint32Array( 10 );
if ( v8[ 0 ] !== 0 ) {
throw new Error( 'something went wrong' );
}
const v9: array.AnyArray = new Uint32Array( 10 );
if ( v9[ 0 ] !== 0 ) {
throw new Error( 'something went wrong' );
}
const v10: array.RealTypedArray = new Uint32Array( 10 );
if ( v10[ 0 ] !== 0 ) {
throw new Error( 'something went wrong' );
}
const v11: array.FloatOrComplexTypedArray = new Float64Array( 10 );
if ( v11[ 0 ] !== 0.0 ) {
throw new Error( 'something went wrong' );
}
}

@@ -151,6 +320,7 @@

{
const data = [ 1, 2, 3 ];
const arr: ndarray.ndarray = {
'byteLength': null,
'BYTES_PER_ELEMENT': null,
'data': [ 1, 2, 3 ],
'data': data,
'dtype': 'generic',

@@ -167,7 +337,7 @@ 'flags': {

'strides': [ 1 ],
'get': ( i: number ): any => {
return arr.data[ i ];
'get': ( i: number ): number => {
return data[ i ];
},
'set': ( i: number, v: any ): ndarray.ndarray => {
arr.data[ i ] = v;
'set': ( i: number, v: number ): ndarray.ndarray => {
data[ i ] = v;
return arr;

@@ -333,2 +503,22 @@ }

}
const z64: obj.Complex64 = {
're': 1.0,
'im': 1.0,
'byteLength': 8,
'BYTES_PER_ELEMENT': 4
};
if ( z64.re !== 1.0 ) {
throw new Error( 'something went wrong' );
}
const z128: obj.Complex128 = {
're': 1.0,
'im': 1.0,
'byteLength': 16,
'BYTES_PER_ELEMENT': 8
};
if ( z128.re !== 1.0 ) {
throw new Error( 'something went wrong' );
}
}

@@ -335,0 +525,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc