mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 17:20:09 +00:00
Add definitions for ndarray
This commit is contained in:
27
ndarray/ndarray-test.ts
Normal file
27
ndarray/ndarray-test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/// <reference path="ndarray.d.ts" />
|
||||
|
||||
import ndarray = require('ndarray');
|
||||
|
||||
const data = new Int32Array(2 * 2 * 2 + 10);
|
||||
const a = ndarray(data, [2, 2, 2], [1, 2, 4], 5);
|
||||
|
||||
console.log(a.data === data);
|
||||
console.log(a.shape[0] === 2);
|
||||
console.log(a.shape[1] === 2);
|
||||
console.log(a.shape[2] === 2);
|
||||
console.log(a.stride[0] === 1);
|
||||
console.log(a.stride[1] === 2);
|
||||
console.log(a.stride[2] === 4);
|
||||
console.log(a.offset === 5);
|
||||
console.log(a.dtype === 'int32');
|
||||
console.log(a.size === 8);
|
||||
console.log(a.order[0] === 0);
|
||||
console.log(a.order[1] === 1);
|
||||
console.log(a.order[2] === 2);
|
||||
console.log(a.dimension === 3);
|
||||
console.log(a.set(0, 0, 0, 1) === 1);
|
||||
console.log(a.get(0, 0, 0) === 1);
|
||||
console.log(a.index(1, 1, 1) === 12);
|
||||
|
||||
const b = a.lo(0, 0, 0).hi(1, 1, 1);
|
||||
const c = b.step(0).transpose(0, 0, 0).pick(null, null, 0);
|
||||
35
ndarray/ndarray.d.ts
vendored
Normal file
35
ndarray/ndarray.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Type definitions for ndarray v1.0.18
|
||||
// Project: https://github.com/scijs/ndarray
|
||||
// Definitions by: Giff Song <https://github.com/pawsong/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'ndarray' {
|
||||
type Data =
|
||||
Array<number> | Int8Array | Int16Array | Int32Array |
|
||||
Uint8Array | Uint16Array | Uint32Array |
|
||||
Float32Array | Float64Array | Uint8ClampedArray;
|
||||
|
||||
interface ndarray {
|
||||
data: Data;
|
||||
shape: number[];
|
||||
stride: number[];
|
||||
offset: number;
|
||||
dtype: 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' |'uint32' |
|
||||
'float32' | 'float64' | 'array'| 'uint8_clamped' | 'buffer' | 'generic';
|
||||
size: number;
|
||||
order: number[];
|
||||
dimension: number;
|
||||
get(...args: number[]): number;
|
||||
set(...args: number[]): number;
|
||||
index(...args: number[]): number;
|
||||
lo(...args: number[]): ndarray;
|
||||
hi(...args: number[]): ndarray;
|
||||
step(...args: number[]): ndarray;
|
||||
transpose(...args: number[]): ndarray;
|
||||
pick(...args: number[]): ndarray;
|
||||
}
|
||||
|
||||
function ndarray(data: Data, shape?: number[], stride?: number[], offset?: number): ndarray;
|
||||
|
||||
export = ndarray;
|
||||
}
|
||||
Reference in New Issue
Block a user