From 2a2f49e0d0e7adfae9782f64fd76a88f93f52647 Mon Sep 17 00:00:00 2001 From: tup1tsa Date: Tue, 11 Sep 2018 04:36:01 +0300 Subject: [PATCH] definitions for numeric (#28714) Please fill in this template. - [x] Use a meaningful title for the pull request. Include the name of the package modified. - [x] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). Select one of these and delete the others: If adding a new definition: - [x] The package does not already provide its own types, or cannot have its `.d.ts` files generated via `--declaration` - [x] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package. - [x] Create it with `dts-gen --dt`, not by basing it on an existing project. - [x] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, `strictNullChecks`, and `strictFunctionTypes` set to `true`. --- types/numeric/index.d.ts | 1199 ++++++++++++++++++++++++++++++++ types/numeric/numeric-tests.ts | 630 +++++++++++++++++ types/numeric/tsconfig.json | 23 + types/numeric/tslint.json | 3 + 4 files changed, 1855 insertions(+) create mode 100644 types/numeric/index.d.ts create mode 100644 types/numeric/numeric-tests.ts create mode 100644 types/numeric/tsconfig.json create mode 100644 types/numeric/tslint.json diff --git a/types/numeric/index.d.ts b/types/numeric/index.d.ts new file mode 100644 index 0000000000..d17791d7f6 --- /dev/null +++ b/types/numeric/index.d.ts @@ -0,0 +1,1199 @@ +// Type definitions for numeric 1.2 +// Project: https://github.com/sloisel/numeric +// Definitions by: Sasha Grin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +// Documentation: http://www.numericjs.com/documentation.html + +type NonNullPrimitive = number | string | boolean | undefined; +type Scalar = number; +type Vector = number[]; +type VectorBoolean = boolean[]; +type Matrix = number[][]; +type SparseMatrix = [Vector, Vector, Vector]; +type DeprecatedSparseMatrix = Array>; +type DeprecatedSparseVector = Array; +type CCSComparisonResult = [Vector, Vector, VectorBoolean]; +type ShapeFunction = (i: number, j: number) => boolean; +interface LUPP { + L: SparseMatrix; + U: SparseMatrix; + P: Vector; + Pinv: Vector; +} +interface LU { + L: Matrix; + U: Matrix; +} +type MultidimensionalArray = + | T[][] + | T[][][] + | T[][][][] + | T[][][][][] + | T[][][][][][] + | T[][][][][][][] + | T[][][][][][][][] + | T[][][][][][][][][][] + | T[][][][][][][][][][][] + | T[][][][][][][][][][][][] + | T[][][][][][][][][][][][][] + | T[][][][][][][][][][][][][][] + | T[][][][][][][][][][][][][][][] + | T[][][][][][][][][][][][][][][][]; +type MultidimensionalMatrix = MultidimensionalArray; + +type TensorValue = Scalar | Vector | MultidimensionalMatrix; +type NonScalar = Vector | MultidimensionalMatrix; + +declare class Tensor { + x: TensorValue; + y?: TensorValue; + + add(tensor: Tensor | TensorValue): Tensor; + sub(tensor: Tensor | TensorValue): Tensor; + mul(tensor: Tensor | TensorValue): Tensor; + // it's buggy. https://github.com/sloisel/numeric/pull/59 + reciprocal(): Tensor; + div(tensor: Tensor | TensorValue): Tensor; + dot(tensor: Tensor | TensorValue): Tensor; + transpose(): Tensor; + transjugate(): Tensor; + exp(): Tensor; + conj(): Tensor; + neg(): Tensor; + sin(): Tensor; + cos(): Tensor; + abs(): Tensor; + log(): Tensor; + norm2(): Tensor; + inv(): Tensor; + get(i: Vector): Tensor; + set(i: Vector, value: Tensor): Tensor; + getRows(i0: number, i1: number): Tensor; + setRows(i0: number, i1: number, tensor: Tensor): Tensor; + getRow(k: number): Tensor; + setRow(i: number, tensor: Tensor): Tensor; + getBlock(from: Vector, to: Vector): Tensor; + setBlock(from: Vector, to: Vector, tensor: Tensor): Tensor; + rep(s: Vector, value: Tensor | TensorValue): Tensor; + diag(d: Tensor | TensorValue): Tensor; + eig(): { lambda: Tensor; E: Tensor }; + identity(n: number): Tensor; + getDiag(): Tensor; + // fast fourier transforms + fft(): Tensor; + ifft(): Tensor; +} + +declare class Spline { + x: Vector; + yl: Vector; + yr: Vector; + kl: Vector; + kr: Vector; + + at(x0: Vector | Scalar): Vector | Scalar; + diff(): Spline; + roots(): Vector; +} + +declare class Dopri { + x: Vector; + y: Vector; + f: Vector; + ymid: Vector; + iterations: number; + msg: string; + events?: boolean | VectorBoolean; + + at(x: Vector): Vector | Matrix; +} + +interface Numeric { + readonly epsilon: number; + largeArray: number; + precision: number; + readonly version: string; + + seedrandom: { + seedrandom(seed: number | string, useEntropy?: boolean): string; + random(): number; + }; + + // utility functions + // Benchmarking routine + bench(func: () => any, interval?: number): number; + prettyPrint(x?: any): string; + parseDate(date: string): number; + parseDate(dates: string[]): number[]; + parseFloat(input: string): number; + parseFloat(inputs: string[]): number[]; + parseCSV(csv: string): string[][]; + // toCSV is buggy. + // https://github.com/sloisel/numeric/pull/51 + toCSV(csvArray: any[][]): string; + // Encode a matrix as an image URL + imageURL(img: number[][]): string; + getURL(url: string): any; + + // linear algebra with arrays + // Get Array dimensions + dim(arr: any): Vector; + // x and y are entrywise identical + same(x: any, y: any): boolean; + // Create an Array by duplicating values + rep(scale: Vector, value: T, key?: number): MultidimensionalArray; + + // Matrix-Matrix, Matrix-Vector, Vector-Matrix and Vector-Vector product + dot( + x: Vector | Matrix | Scalar, + y: Vector | Matrix | Scalar + ): Vector | Matrix | Scalar; + dotMMsmall(x: Matrix, y: Matrix): Matrix; + dotMMbig(x: Matrix, y: Matrix): Matrix; + dotMV(x: Matrix, y: Vector): Vector; + dotVM(x: Vector, y: Matrix): Vector; + dotVV(x: Vector, y: Vector): Scalar; + + // Create diagonal matrix + diag(diagonal: Vector): Matrix; + // Get the diagonal of a Matrix + getDiag(matrix: Matrix): Vector; + // Identity matrix + identity(num: number): Matrix; + + // Pointwise Math.abs(x) + abs(x: T): T; + absV(x: Vector): Vector; + abseqV(x: Vector): Vector; + abseq(x: T): T; + + // Pointwise arc-cosine + acos(x: T): T; + acosV(x: Vector): Vector; + acoseqV(x: Vector): Vector; + acoseq(x: T): T; + + // Pointwise arc-sine + asin(x: T): T; + asinV(x: Vector): Vector; + asineqV(x: Vector): Vector; + asineq(x: T): T; + + // Pointwise arc-tangent + atan(x: T): T; + atanV(x: Vector): Vector; + ataneqV(x: Vector): Vector; + ataneq(x: T): T; + + // Pointwise Math.ceil(x) + ceil(x: T): T; + ceilV(x: Vector): Vector; + ceileqV(x: Vector): Vector; + ceileq(x: T): T; + + // Pointwise Math.cos(x) + cos(x: T): T; + cosV(x: Vector): Vector; + coseqV(x: Vector): Vector; + coseq(x: T): T; + + // Pointwise Math.exp(x) + exp(x: T): T; + expV(x: Vector): Vector; + expeqV(x: Vector): Vector; + expeq(x: T): T; + + // Poinwise Math.floor(x) + floor(x: T): T; + floorV(x: Vector): Vector; + flooreqV(x: Vector): Vector; + flooreq(x: T): T; + + // Pointwise Math.log(x) + log(x: T): T; + logV(x: Vector): Vector; + logeqV(x: Vector): Vector; + logeq(x: T): T; + + // Pointwise Math.round(x) + round(x: T): T; + roundV(x: Vector): Vector; + roundeqV(x: Vector): Vector; + roundeq(x: T): T; + + // Pointwise Math.sin(x) + sin(x: T): T; + sinV(x: Vector): Vector; + sineqV(x: Vector): Vector; + sineq(x: T): T; + + // Pointwise Math.sqrt(x) + sqrt(x: T): T; + sqrtV(x: Vector): Vector; + sqrteqV(x: Vector): Vector; + sqrteq(x: T): T; + + // Pointwise tangent + tan(x: T): T; + tanV(x: Vector): Vector; + taneqV(x: Vector): Vector; + taneq(x: T): T; + + // Pointwise Number.isNan(x) + isNaN(x: Vector): VectorBoolean; + isNaN(x: MultidimensionalMatrix): MultidimensionalArray; + isNaNV(x: Vector): VectorBoolean; + isNaNeqV(x: Vector): VectorBoolean; + isNaNeq(x: Vector): VectorBoolean; + isNaNeq(x: MultidimensionalMatrix): MultidimensionalArray; + + // Pointwise Number.isFinite(x) + isFinite(x: Vector): VectorBoolean; + isFinite(x: MultidimensionalMatrix): MultidimensionalArray; + isFiniteV(x: Vector): VectorBoolean; + isFiniteeqV(x: Vector): VectorBoolean; + isFiniteeq(x: Vector): VectorBoolean; + isFiniteeq(x: MultidimensionalMatrix): MultidimensionalArray; + + // Pointwise -x + neg(x: T): T; + negV(x: Vector): Vector; + negeq(x: T): T; + negeqV(x: Vector): Vector; + + // Pointwise logical negation !x + not(x: NonNullPrimitive): boolean; + not(x: NonNullPrimitive[]): VectorBoolean; + not( + x: MultidimensionalArray + ): MultidimensionalArray; + notV(x: NonNullPrimitive[]): VectorBoolean; + noteq(x: NonNullPrimitive): boolean; + noteq(x: NonNullPrimitive[]): VectorBoolean; + noteq( + x: MultidimensionalArray + ): MultidimensionalArray; + noteqV(x: NonNullPrimitive[]): VectorBoolean; + + // Pointwise binary negation ~x + bnot(x: T): T; + bnotV(x: Vector): Vector; + bnoteq(x: T): T; + bnoteqV(x: Vector): Vector; + + // Deep copy of Array + clone< + T extends NonNullPrimitive[] | MultidimensionalArray + >( + x: T + ): T; + cloneV(x: NonNullPrimitive[]): NonNullPrimitive[]; + cloneeq(x: NonNullPrimitive[]): NonNullPrimitive[]; + cloneeq< + T extends NonNullPrimitive[] | MultidimensionalArray + >( + x: T + ): T; + cloneeqV(x: NonNullPrimitive[]): NonNullPrimitive[]; + + // Pointwise sum x+y + add(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + add( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + add( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "+"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "+"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "+"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + addVV(x: Vector, y: Vector): Vector; + addSV(x: Scalar, y: Vector): Vector; + addVS(x: Vector, y: Scalar): Vector; + addeq(x: Vector, y: Vector | Scalar): Vector; + addeqV(x: Vector, y: Vector): Vector; + addeqS(x: Vector, y: Scalar): Vector; + + // Pointwise x-y + sub(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + sub( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + sub( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "-"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "-"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "-"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + subVV(x: Vector, y: Vector): Vector; + subSV(x: Scalar, y: Vector): Vector; + subVS(x: Vector, y: Scalar): Vector; + subeq(x: Vector, y: Vector | Scalar): Vector; + subeqV(x: Vector, y: Vector): Vector; + subeqS(x: Vector, y: Scalar): Vector; + + // Pointwise x*y + mul(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + mul( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + mul( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "*"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "*"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "*"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + mulVV(x: Vector, y: Vector): Vector; + mulSV(x: Scalar, y: Vector): Vector; + mulVS(x: Vector, y: Scalar): Vector; + muleq(x: Vector, y: Vector | Scalar): Vector; + muleqV(x: Vector, y: Vector): Vector; + muleqS(x: Vector, y: Scalar): Vector; + + // Pointwise x/y + div(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + div( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + div( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "/"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "/"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "/"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + divVV(x: Vector, y: Vector): Vector; + divSV(x: Scalar, y: Vector): Vector; + divVS(x: Vector, y: Scalar): Vector; + diveq(x: Vector, y: Vector | Scalar): Vector; + diveqV(x: Vector, y: Vector): Vector; + diveqS(x: Vector, y: Scalar): Vector; + + // Pointwise x%y + mod(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + mod( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + mod( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "%"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "%"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "%"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + modVV(x: Vector, y: Vector): Vector; + modSV(x: Scalar, y: Vector): Vector; + modVS(x: Vector, y: Scalar): Vector; + modeq(x: Vector, y: Vector | Scalar): Vector; + modeqV(x: Vector, y: Vector): Vector; + modeqS(x: Vector, y: Scalar): Vector; + + // Pointwise x && y + and(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + and( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + and( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "&&"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "&&"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "&&"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + andVV(x: Vector, y: Vector): Vector; + andSV(x: Scalar, y: Vector): Vector; + andVS(x: Vector, y: Scalar): Vector; + andeq(x: Vector, y: Vector | Scalar): Vector; + andeqV(x: Vector, y: Vector): Vector; + andeqS(x: Vector, y: Scalar): Vector; + + // Pointwise logical or x||y + or(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + or( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + or( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "||"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "||"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "||"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + orVV(x: Vector, y: Vector): Vector; + orSV(x: Scalar, y: Vector): Vector; + orVS(x: Vector, y: Scalar): Vector; + oreq(x: Vector, y: Vector | Scalar): Vector; + oreqV(x: Vector, y: Vector): Vector; + oreqS(x: Vector, y: Scalar): Vector; + + // Pointwise comparison x === y + eq(x: Scalar, y: Scalar): boolean; + eq(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + eq( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + "==="(x: Scalar, y: Scalar, ...args: Scalar[]): boolean; + "==="(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + "==="( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + eqVV(x: Vector, y: Vector): VectorBoolean; + eqSV(x: Scalar, y: Vector): VectorBoolean; + eqVS(x: Vector, y: Scalar): VectorBoolean; + eqeq(x: Vector, y: Vector | Scalar): VectorBoolean; + eqeqV(x: Vector, y: Vector): VectorBoolean; + eqeqS(x: Vector, y: Scalar): VectorBoolean; + + // Pointwise x!==y + neq(x: Scalar, y: Scalar): boolean; + neq(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + neq( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + "!=="(x: Scalar, y: Scalar, ...args: Scalar[]): boolean; + "!=="(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + "!=="( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + neqVV(x: Vector, y: Vector): VectorBoolean; + neqSV(x: Scalar, y: Vector): VectorBoolean; + neqVS(x: Vector, y: Scalar): VectorBoolean; + neqeq(x: Vector, y: Vector | Scalar): VectorBoolean; + neqeqV(x: Vector, y: Vector): VectorBoolean; + neqeqS(x: Vector, y: Scalar): VectorBoolean; + + // Pointwise x; + "<"(x: Scalar, y: Scalar, ...args: Scalar[]): boolean; + "<"(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + "<"( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + ltVV(x: Vector, y: Vector): VectorBoolean; + ltSV(x: Scalar, y: Vector): VectorBoolean; + ltVS(x: Vector, y: Scalar): VectorBoolean; + lteq(x: Vector, y: Vector | Scalar): VectorBoolean; + lteqV(x: Vector, y: Vector): VectorBoolean; + lteqS(x: Vector, y: Scalar): VectorBoolean; + + // Pointwise x>y + gt(x: Scalar, y: Scalar): boolean; + gt(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + gt( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + ">"(x: Scalar, y: Scalar, ...args: Scalar[]): boolean; + ">"(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + ">"( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + gtVV(x: Vector, y: Vector): VectorBoolean; + gtSV(x: Scalar, y: Vector): VectorBoolean; + gtVS(x: Vector, y: Scalar): VectorBoolean; + gteq(x: Vector, y: Vector | Scalar): VectorBoolean; + gteqV(x: Vector, y: Vector): VectorBoolean; + gteqS(x: Vector, y: Scalar): VectorBoolean; + + // Pointwise x<=y + leq(x: Scalar, y: Scalar): boolean; + leq(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + leq( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + "<="(x: Scalar, y: Scalar, ...args: Scalar[]): boolean; + "<="(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + "<="( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + leqVV(x: Vector, y: Vector): VectorBoolean; + leqSV(x: Scalar, y: Vector): VectorBoolean; + leqVS(x: Vector, y: Scalar): VectorBoolean; + leqeq(x: Vector, y: Vector | Scalar): VectorBoolean; + leqeqV(x: Vector, y: Vector): VectorBoolean; + leqeqS(x: Vector, y: Scalar): VectorBoolean; + + // Pointwise x>=y + geq(x: Scalar, y: Scalar): boolean; + geq(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + geq( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + ">="(x: Scalar, y: Scalar, ...args: Scalar[]): boolean; + ">="(x: Scalar | Vector, y: Scalar | Vector): VectorBoolean; + ">="( + x: MultidimensionalMatrix, + y: MultidimensionalMatrix + ): MultidimensionalArray; + geqVV(x: Vector, y: Vector): VectorBoolean; + geqSV(x: Scalar, y: Vector): VectorBoolean; + geqVS(x: Vector, y: Scalar): VectorBoolean; + geqeq(x: Vector, y: Vector | Scalar): VectorBoolean; + geqeqV(x: Vector, y: Vector): VectorBoolean; + geqeqS(x: Vector, y: Scalar): VectorBoolean; + + // Pointwise x & y + band(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + band( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + band( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "&"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "&"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "&"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + bandVV(x: Vector, y: Vector): Vector; + bandSV(x: Scalar, y: Vector): Vector; + bandVS(x: Vector, y: Scalar): Vector; + bandeq(x: Vector, y: Vector | Scalar): Vector; + bandeqV(x: Vector, y: Vector): Vector; + bandeqS(x: Vector, y: Scalar): Vector; + + // Pointwise binary or x|y + bor(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + bor( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + bor( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "|"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "|"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "|"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + borVV(x: Vector, y: Vector): Vector; + borSV(x: Scalar, y: Vector): Vector; + borVS(x: Vector, y: Scalar): Vector; + boreq(x: Vector, y: Vector | Scalar): Vector; + boreqV(x: Vector, y: Vector): Vector; + boreqS(x: Vector, y: Scalar): Vector; + + // Pointwise binary xor x^y + bxor(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + bxor( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + bxor( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "^"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "^"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "^"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + bxorVV(x: Vector, y: Vector): Vector; + bxorSV(x: Scalar, y: Vector): Vector; + bxorVS(x: Vector, y: Scalar): Vector; + bxoreq(x: Vector, y: Vector | Scalar): Vector; + bxoreqV(x: Vector, y: Vector): Vector; + bxoreqS(x: Vector, y: Scalar): Vector; + + // Pointwise x< + ): Vector; + lshift( + x: T, + y: T | Scalar, + ...args: Array + ): T; + "<<"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + "<<"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + "<<"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + lshiftVV(x: Vector, y: Vector): Vector; + lshiftSV(x: Scalar, y: Vector): Vector; + lshiftVS(x: Vector, y: Scalar): Vector; + lshifteq(x: Vector, y: Vector | Scalar): Vector; + lshifteqV(x: Vector, y: Vector): Vector; + lshifteqS(x: Vector, y: Scalar): Vector; + + // Pointwise x>>y + rshift(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + rshift( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + rshift( + x: T, + y: T | Scalar, + ...args: Array + ): T; + ">>"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + ">>"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + ">>"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + rshiftVV(x: Vector, y: Vector): Vector; + rshiftSV(x: Scalar, y: Vector): Vector; + rshiftVS(x: Vector, y: Scalar): Vector; + rshifteq(x: Vector, y: Vector | Scalar): Vector; + rshifteqV(x: Vector, y: Vector): Vector; + rshifteqS(x: Vector, y: Scalar): Vector; + + // Pointwise x>>>y + rrshift(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + rrshift( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + rrshift( + x: T, + y: T | Scalar, + ...args: Array + ): T; + ">>>"(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + ">>>"( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + ">>>"( + x: T, + y: T | Scalar, + ...args: Array + ): T; + rrshiftVV(x: Vector, y: Vector): Vector; + rrshiftSV(x: Scalar, y: Vector): Vector; + rrshiftVS(x: Vector, y: Scalar): Vector; + rrshifteq(x: Vector, y: Vector | Scalar): Vector; + rrshifteqV(x: Vector, y: Vector): Vector; + rrshifteqS(x: Vector, y: Scalar): Vector; + + // Pointwise arc-tangent (two parameters) + atan2(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + atan2( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + atan2( + x: T, + y: T | Scalar, + ...args: Array + ): T; + atan2VV(x: Vector, y: Vector): Vector; + atan2SV(x: Scalar, y: Vector): Vector; + atan2VS(x: Vector, y: Scalar): Vector; + atan2eq(x: Vector, y: Vector | Scalar): Vector; + atan2eqV(x: Vector, y: Vector): Vector; + atan2eqS(x: Vector, y: Scalar): Vector; + + // Pointwise x**y + pow(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + pow( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + pow( + x: T, + y: T | Scalar, + ...args: Array + ): T; + powVV(x: Vector, y: Vector): Vector; + powSV(x: Scalar, y: Vector): Vector; + powVS(x: Vector, y: Scalar): Vector; + poweq(x: Vector, y: Vector | Scalar): Vector; + poweqV(x: Vector, y: Vector): Vector; + poweqS(x: Vector, y: Scalar): Vector; + + // Pointwise max(x,y) + max(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + max( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + max( + x: T, + y: T | Scalar, + ...args: Array + ): T; + maxVV(x: Vector, y: Vector): Vector; + maxSV(x: Scalar, y: Vector): Vector; + maxVS(x: Vector, y: Scalar): Vector; + maxeq(x: Vector, y: Vector | Scalar): Vector; + maxeqV(x: Vector, y: Vector): Vector; + maxeqS(x: Vector, y: Scalar): Vector; + + // Pointwise min(x,y) + min(x: Scalar, y: Scalar, ...args: Scalar[]): Scalar; + min( + x: Scalar | Vector, + y: Scalar | Vector, + ...args: Array + ): Vector; + min( + x: T, + y: T | Scalar, + ...args: Array + ): T; + minVV(x: Vector, y: Vector): Vector; + minSV(x: Scalar, y: Vector): Vector; + minVS(x: Vector, y: Scalar): Vector; + mineq(x: Vector, y: Vector | Scalar): Vector; + mineqV(x: Vector, y: Vector): Vector; + mineqS(x: Vector, y: Scalar): Vector; + + // One or more of the components of x are true + any(x: any): boolean; + anyV(x: any[]): boolean; + + // All the components of x are true + all(x: any): boolean; + allV(x: any[]): boolean; + + // Sum all the entries of x + sum(x: Scalar | Vector | MultidimensionalMatrix): number; + sumV(x: Vector): number; + + // Product of all the entries of x + prod(x: Scalar | Vector | MultidimensionalMatrix): number; + prodV(x: Vector): number; + + // Sum of squares of entries of x + norm2Squared(x: Scalar | Vector | MultidimensionalMatrix): number; + norm2SquaredV(x: Vector): number; + + // Largest modulus entry of x + norminf(x: Scalar | Vector | MultidimensionalMatrix): number; + norminfV(x: Vector): number; + + // Sum all absolute values of entries + norm1(x: Scalar | Vector | MultidimensionalMatrix): number; + norm1V(x: Vector): number; + + // Largest value of entries (not modulus) + sup(x: Scalar | Vector | MultidimensionalMatrix): number; + supV(x: Vector): number; + + // Smallest value of entries (not modulus) + inf(x: Scalar | Vector | MultidimensionalMatrix): number; + infV(x: Vector): number; + + // Round the values of entries + truncVV(x: Vector, y: Vector): Vector; + truncVS(x: Vector, y: number): Vector; + truncSV(x: number, y: Vector): Vector; + trunc(x: number | Vector, y: number | Vector): Vector; + + // Matrix inverse + inv(x: Matrix): Matrix; + // Determinant + det(x: Matrix): number; + // Matrix transpose + transpose(x: Matrix): Matrix; + // Negate matrix and transpose + negtranspose(x: Matrix): Matrix; + // Create an Array of random numbers + random(s: Vector): Vector | MultidimensionalMatrix; + // Square root of the sum of the square of the entries of x + norm2(x: Scalar | Vector | MultidimensionalMatrix): number; + // Generate evenly spaced values + linspace(from: number, to: number, numberOfValues?: number): Vector; + // Extract a block from a matrix + getBlock( + x: T, + from: Vector, + to: Vector + ): T; + // Set a block of a matrix + setBlock( + x: T, + from: Vector, + to: Vector, + b: T + ): T; + // create two-dimensional matrix + blockMatrix(x: Scalar | Vector | MultidimensionalMatrix): Matrix; + // x * y + tensor(x: Scalar, y: Scalar): Scalar; + // TensorValue product ret[i][j] = x[i]*y[j] + tensor(x: Vector, y: Vector): Matrix; + + // return instance of Tensor class. X — real value, y — imaginary part. + t(x: TensorValue, y?: TensorValue): Tensor; + + // Eigenvalues of real matrices + house(x: Vector): Vector; + toUpperHessenberg(matrix: Matrix): { H: Matrix; Q: Matrix }; + QRFrancis(x: Matrix, maxiter?: number): { Q: Matrix; B: Matrix }; + eig(A: Matrix, maxiter?: number): { lambda: Tensor; E: Tensor }; + + // Compressed Column Storage matrices + ccsSparse(matrix: Matrix): SparseMatrix; + ccsFull(matrix: SparseMatrix): Matrix; + ccsTSolve( + matrix: SparseMatrix, + b: Vector, + x?: Vector, + bj?: Vector, + xj?: Vector + ): Vector; + ccsDot(A: SparseMatrix, B: SparseMatrix): SparseMatrix; + ccsLUP(matrix: SparseMatrix, threshold?: number): LUPP; + ccsDim(matrix: SparseMatrix): Vector; + ccsGetBlock( + matrix: SparseMatrix, + i?: Vector | Scalar, + j?: Vector | Scalar + ): SparseMatrix; + ccsLUPSolve(lup: LUPP, B: SparseMatrix): Vector; + ccsScatter(matrix: SparseMatrix): SparseMatrix; + ccsGather(matrix: SparseMatrix): SparseMatrix; + + ccsadd(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsadd(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsaddMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccssub(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccssub(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccssubMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsmul(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsmul(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsmulMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsdiv(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsdiv(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsdivMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsmod(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsmod(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsmodMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsand(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsand(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsandMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsor(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsor(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsorMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccseq(x: SparseMatrix, y: Scalar | SparseMatrix): CCSComparisonResult; + ccseq(x: Scalar | SparseMatrix, y: SparseMatrix): CCSComparisonResult; + ccseqMM(x: SparseMatrix, y: SparseMatrix): CCSComparisonResult; + + ccsneq(x: SparseMatrix, y: Scalar | SparseMatrix): CCSComparisonResult; + ccsneq(x: Scalar | SparseMatrix, y: SparseMatrix): CCSComparisonResult; + ccsneqMM(x: SparseMatrix, y: SparseMatrix): CCSComparisonResult; + + ccslt(x: SparseMatrix, y: Scalar | SparseMatrix): CCSComparisonResult; + ccslt(x: Scalar | SparseMatrix, y: SparseMatrix): CCSComparisonResult; + ccsltMM(x: SparseMatrix, y: SparseMatrix): CCSComparisonResult; + + ccsgt(x: SparseMatrix, y: Scalar | SparseMatrix): CCSComparisonResult; + ccsgt(x: Scalar | SparseMatrix, y: SparseMatrix): CCSComparisonResult; + ccsgtMM(x: SparseMatrix, y: SparseMatrix): CCSComparisonResult; + + ccsleq(x: SparseMatrix, y: Scalar | SparseMatrix): CCSComparisonResult; + ccsleq(x: Scalar | SparseMatrix, y: SparseMatrix): CCSComparisonResult; + ccsleqMM(x: SparseMatrix, y: SparseMatrix): CCSComparisonResult; + + ccsgeq(x: SparseMatrix, y: Scalar | SparseMatrix): CCSComparisonResult; + ccsgeq(x: Scalar | SparseMatrix, y: SparseMatrix): CCSComparisonResult; + ccsgeqMM(x: SparseMatrix, y: SparseMatrix): CCSComparisonResult; + + ccsband(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsband(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsbandMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsbor(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsbor(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsborMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsbxor(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsbxor(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsbxorMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccslshift(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccslshift(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccslshiftMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsrshift(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsrshift(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsrshiftMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + ccsrrshift(x: SparseMatrix, y: Scalar | SparseMatrix): SparseMatrix; + ccsrrshift(x: Scalar | SparseMatrix, y: SparseMatrix): SparseMatrix; + ccsrrshiftMM(x: SparseMatrix, y: SparseMatrix): SparseMatrix; + + /** @deprecated */ + sdim(matrix: any, ret?: Vector, k?: number): Vector; + /** @deprecated */ + sclone(matrix: T, k?: number, n?: number): T; + /** @deprecated */ + sdiag(d: Vector): DeprecatedSparseMatrix; + /** @deprecated */ + sidentity(n: Scalar): DeprecatedSparseMatrix; + /** @deprecated */ + stranspose(matrix: DeprecatedSparseMatrix): DeprecatedSparseMatrix; + /** @deprecated */ + sdotMM( + a: DeprecatedSparseMatrix, + b: DeprecatedSparseMatrix + ): DeprecatedSparseMatrix; + /** @deprecated */ + sdotMV( + matrix: DeprecatedSparseMatrix, + vector: DeprecatedSparseVector + ): DeprecatedSparseVector; + /** @deprecated */ + sdotVM( + vector: DeprecatedSparseVector, + matrix: DeprecatedSparseMatrix + ): DeprecatedSparseMatrix; + /** @deprecated */ + sdotVV(x: DeprecatedSparseVector, y: DeprecatedSparseVector): number; + /** @deprecated */ + sdot( + x: Scalar | DeprecatedSparseVector | DeprecatedSparseMatrix, + y: Scalar | DeprecatedSparseVector | DeprecatedSparseMatrix + ): Scalar | DeprecatedSparseVector | DeprecatedSparseMatrix; + /** @deprecated */ + sscatter(matrix: DeprecatedSparseMatrix): DeprecatedSparseMatrix; + /** @deprecated */ + sgather( + matrix: DeprecatedSparseMatrix, + ret?: DeprecatedSparseVector, + k?: DeprecatedSparseVector + ): DeprecatedSparseMatrix; + + // Coordinate matrices + cLU(matrix: Matrix): LU; + cLUSolve(lu: LU, b: Vector): Vector; + cgrid(n: number | [number, number], shape?: "L" | ShapeFunction): Matrix; + cdelsq(g: Matrix): Matrix; + cdotmv(matrix: Matrix, x: Vector): Vector; + + // Splines + spline( + x: Vector, + y: Vector | Matrix, + k1?: "periodic" | Scalar, + kn?: "periodic" | Scalar + ): Spline; + + // Unconstrained optimisations + uncmin( + f: (x: Vector) => Scalar, + x0: Vector, + tol?: number, + gradient?: any, + maxit?: number, + callback?: ( + it: number, + x0: Vector, + f0: Scalar, + g0: Vector, + h1: Matrix + ) => any, + options?: { Hinv: Matrix } + ): { + solution: Vector; + f: Scalar; + gradient: Vector; + invHessian: Matrix; + iterations: number; + message: string; + }; + gradient(f: (x: Vector) => Scalar, x: Vector): Vector; + + // Ode solver (Dormand-Prince) + dopri( + x0: Scalar, + x1: Scalar, + y0: Scalar, + f: (x: Vector | Scalar, y: Vector | Scalar) => Vector | Scalar, + tol?: number, + maxit?: number, + event?: (x: Vector | Scalar, y: Vector | Scalar) => Vector | Scalar + ): Dopri; + + // Solving the linear problem Ax=b + solve(matrix: Matrix, vector: Vector): Vector; + LU(matrix: Matrix, fast?: boolean): { LU: Matrix; P: Vector }; + LUsolve(lup: { LU: Matrix; P: Vector }, vector: Vector): Vector; + + // Linear programming + echelonize(matrix: Matrix): { I: Matrix; A: Matrix; P: Vector }; + solveLP( + c: Vector, + A: Matrix, + b: Vector, + Aeq?: Matrix, + beq?: Matrix, + tol?: number, + maxit?: number + ): { solution: Scalar | Vector; message: string; iterations: number }; + + solveQP( + Dmat: Matrix, + dvec: Vector, + Amat: Matrix, + bvec: Vector, + meq?: number, + factorized?: any + ): { + solution: Vector; + value: Vector; + unconstrained_solution: Vector; + iterations: Vector; + iact: Vector; + message: string; + }; + + svd(matrix: Matrix): { U: Matrix; S: Vector; V: Matrix }; +} + +declare const numeric: Numeric; +export = numeric; diff --git a/types/numeric/numeric-tests.ts b/types/numeric/numeric-tests.ts new file mode 100644 index 0000000000..017f3ae6cd --- /dev/null +++ b/types/numeric/numeric-tests.ts @@ -0,0 +1,630 @@ +import numeric = require("numeric"); + +const vector = [2, 5]; +const matrix = [vector, vector]; +const threeDimensionalMatrix = [[[2, 3], [2, 3], [3, 5]]]; +const sparseMatrix: [number[], number[], number[]] = [vector, vector, vector]; + +numeric.bench(() => null, 150); // $ExpectType number +numeric.prettyPrint(vector); // $ExpectType string +numeric.parseDate("08-08-17"); // $ExpectType number +numeric.parseDate(["08-05-87", "08-05-75"]); // $ExpectType number[] +numeric.parseFloat("55.24"); // $ExpectType number +numeric.parseFloat(["25.15", "44.25", "as"]); // $ExpectType number[] +numeric.parseCSV("car, bike"); // $ExpectType string[][] +numeric.toCSV([[25, 52, 62, 66], ["car", "bad", "bike", {}]]); // $ExpectType string +numeric.imageURL([[25, 50], [52, 52]]); // $ExpectType string +numeric.getURL('sdf'); // $ExpectType any + +numeric.dim(matrix); // $ExpectType number[] +numeric.same(25, [25]); // $ExpectType boolean +numeric.rep([2, 5], true); +numeric.dotMMsmall(matrix, matrix); // $ExpectType number[][] +numeric.dotMMbig(matrix, matrix); // $ExpectType number[][] +numeric.dotMV(matrix, vector); // $ExpectType number[] +numeric.dotVM(vector, matrix); // $ExpectType number[] +numeric.dotVV(vector, vector); // $ExpectType number +numeric.dot(vector, matrix); // $ExpectType number | number[] | number[][] +numeric.diag([25, 52]); // $ExpectType number[][] +numeric.getDiag(matrix); // $ExpectType number[] +numeric.identity(24); // $ExpectType number[][] + +numeric.abs(matrix); // $ExpectType number[][] +numeric.absV(vector); // $ExpectType number[] +numeric.abseqV(vector); // $ExpectType number[] +numeric.abseq(matrix); // $ExpectType number[][] + +numeric.acos(matrix); // $ExpectType number[][] +numeric.acosV(vector); // $ExpectType number[] +numeric.acoseqV(vector); // $ExpectType number[] +numeric.acoseq(matrix); // $ExpectType number[][] + +numeric.asin(matrix); // $ExpectType number[][] +numeric.asinV(vector); // $ExpectType number[] +numeric.asineqV(vector); // $ExpectType number[] +numeric.asineq(matrix); // $ExpectType number[][] + +numeric.atan(matrix); // $ExpectType number[][] +numeric.atanV(vector); // $ExpectType number[] +numeric.ataneqV(vector); // $ExpectType number[] +numeric.ataneq(matrix); // $ExpectType number[][] + +numeric.ceil(matrix); // $ExpectType number[][] +numeric.ceilV(vector); // $ExpectType number[] +numeric.ceileqV(vector); // $ExpectType number[] +numeric.ceileq(matrix); // $ExpectType number[][] + +numeric.cos(matrix); // $ExpectType number[][] +numeric.cosV(vector); // $ExpectType number[] +numeric.coseqV(vector); // $ExpectType number[] +numeric.coseq(matrix); // $ExpectType number[][] + +numeric.exp(matrix); // $ExpectType number[][] +numeric.expV(vector); // $ExpectType number[] +numeric.expeqV(vector); // $ExpectType number[] +numeric.expeq(matrix); // $ExpectType number[][] + +numeric.floor(matrix); // $ExpectType number[][] +numeric.floorV(vector); // $ExpectType number[] +numeric.flooreqV(vector); // $ExpectType number[] +numeric.flooreq(matrix); // $ExpectType number[][] + +numeric.log(matrix); // $ExpectType number[][] +numeric.logV(vector); // $ExpectType number[] +numeric.logeqV(vector); // $ExpectType number[] +numeric.logeq(matrix); // $ExpectType number[][] + +numeric.round(matrix); // $ExpectType number[][] +numeric.roundV(vector); // $ExpectType number[] +numeric.roundeqV(vector); // $ExpectType number[] +numeric.roundeq(matrix); // $ExpectType number[][] + +numeric.sin(matrix); // $ExpectType number[][] +numeric.sinV(vector); // $ExpectType number[] +numeric.sineqV(vector); // $ExpectType number[] +numeric.sineq(matrix); // $ExpectType number[][] + +numeric.sqrt(matrix); // $ExpectType number[][] +numeric.sqrtV(vector); // $ExpectType number[] +numeric.sqrteqV(vector); // $ExpectType number[] +numeric.sqrteq(matrix); // $ExpectType number[][] + +numeric.tan(matrix); // $ExpectType number[][] +numeric.tanV(vector); // $ExpectType number[] +numeric.taneqV(vector); // $ExpectType number[] +numeric.taneq(matrix); // $ExpectType number[][] + +numeric.isNaN(vector); // $ExpectType boolean[] +numeric.isNaN(threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.isNaNV(vector); // $ExpectType boolean[] +numeric.isNaNeqV(vector); // $ExpectType boolean[] +numeric.isNaNeq(vector); // $ExpectType boolean[] +numeric.isNaNeq(threeDimensionalMatrix); // $ExpectType MultidimensionalArray + +numeric.isFinite(vector); // $ExpectType boolean[] +numeric.isFinite(threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.isFiniteV(vector); // $ExpectType boolean[] +numeric.isFiniteeqV(vector); // $ExpectType boolean[] +numeric.isFiniteeq(vector); // $ExpectType boolean[] +numeric.isFiniteeq(threeDimensionalMatrix); // $ExpectType MultidimensionalArray + +numeric.neg(matrix); // $ExpectType number[][] +numeric.negV(vector); // $ExpectType number[] +numeric.negeqV(vector); // $ExpectType number[] +numeric.negeq(matrix); // $ExpectType number[][] + +numeric.bnot(matrix); // $ExpectType number[][] +numeric.bnotV(vector); // $ExpectType number[] +numeric.bnoteqV(vector); // $ExpectType number[] +numeric.bnoteq(matrix); // $ExpectType number[][] + +numeric.not(2); // $ExpectType boolean +numeric.not(vector); // $ExpectType boolean[] +numeric.not(threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.notV(vector); // $ExpectType boolean[] +numeric.noteq(2); // $ExpectType boolean +numeric.noteq(vector); // $ExpectType boolean[] +numeric.noteq(threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.noteqV(vector); // $ExpectType boolean[] + +numeric.clone(vector); // $ExpectType number[] +numeric.cloneV(vector); // $ExpectType NonNullPrimitive[] +numeric.cloneeq(vector); // $ExpectType NonNullPrimitive[] +numeric.cloneeqV(vector); // $ExpectType NonNullPrimitive[] + +numeric.add(2, 5, 6); // $ExpectType number +numeric.add(2, 3, vector); // $ExpectType number[] +numeric.add(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["+"](2, 5, 6); // $ExpectType number +numeric["+"](2, 3, vector); // $ExpectType number[] +numeric["+"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.addVV(vector, vector); // $ExpectType number[] +numeric.addSV(2, vector); // $ExpectType number[] +numeric.addVS(vector, 2); // $ExpectType number[] +numeric.addeq(vector, 3); // $ExpectType number[] +numeric.addeqV(vector, vector); // $ExpectType number[] +numeric.addeqS(vector, 3); // $ExpectType number[] + +numeric.sub(2, 5, 6); // $ExpectType number +numeric.sub(2, 3, vector); // $ExpectType number[] +numeric.sub(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["-"](2, 5, 6); // $ExpectType number +numeric["-"](2, 3, vector); // $ExpectType number[] +numeric["-"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.subVV(vector, vector); // $ExpectType number[] +numeric.subSV(2, vector); // $ExpectType number[] +numeric.subVS(vector, 2); // $ExpectType number[] +numeric.subeq(vector, 3); // $ExpectType number[] +numeric.subeqV(vector, vector); // $ExpectType number[] +numeric.subeqS(vector, 3); // $ExpectType number[] + +numeric.mul(2, 5, 6); // $ExpectType number +numeric.mul(2, 3, vector); // $ExpectType number[] +numeric.mul(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["*"](2, 5, 6); // $ExpectType number +numeric["*"](2, 3, vector); // $ExpectType number[] +numeric["*"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.mulVV(vector, vector); // $ExpectType number[] +numeric.mulSV(2, vector); // $ExpectType number[] +numeric.mulVS(vector, 2); // $ExpectType number[] +numeric.muleq(vector, 3); // $ExpectType number[] +numeric.muleqV(vector, vector); // $ExpectType number[] +numeric.muleqS(vector, 3); // $ExpectType number[] + +numeric.div(2, 5, 6); // $ExpectType number +numeric.div(2, 3, vector); // $ExpectType number[] +numeric.div(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["/"](2, 5, 6); // $ExpectType number +numeric["/"](2, 3, vector); // $ExpectType number[] +numeric["/"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.divVV(vector, vector); // $ExpectType number[] +numeric.divSV(2, vector); // $ExpectType number[] +numeric.divVS(vector, 2); // $ExpectType number[] +numeric.diveq(vector, 3); // $ExpectType number[] +numeric.diveqV(vector, vector); // $ExpectType number[] +numeric.diveqS(vector, 3); // $ExpectType number[] + +numeric.mod(2, 5, 6); // $ExpectType number +numeric.mod(2, 3, vector); // $ExpectType number[] +numeric.mod(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["%"](2, 5, 6); // $ExpectType number +numeric["%"](2, 3, vector); // $ExpectType number[] +numeric["%"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.modVV(vector, vector); // $ExpectType number[] +numeric.modSV(2, vector); // $ExpectType number[] +numeric.modVS(vector, 2); // $ExpectType number[] +numeric.modeq(vector, 3); // $ExpectType number[] +numeric.modeqV(vector, vector); // $ExpectType number[] +numeric.modeqS(vector, 3); // $ExpectType number[] + +numeric.and(2, 5, 6); // $ExpectType number +numeric.and(2, 3, vector); // $ExpectType number[] +numeric.and(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["&&"](2, 5, 6); // $ExpectType number +numeric["&&"](2, 3, vector); // $ExpectType number[] +numeric["&&"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.andVV(vector, vector); // $ExpectType number[] +numeric.andSV(2, vector); // $ExpectType number[] +numeric.andVS(vector, 2); // $ExpectType number[] +numeric.andeq(vector, 3); // $ExpectType number[] +numeric.andeqV(vector, vector); // $ExpectType number[] +numeric.andeqS(vector, 3); // $ExpectType number[] + +numeric.or(2, 5, 6); // $ExpectType number +numeric.or(2, 3, vector); // $ExpectType number[] +numeric.or(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["||"](2, 5, 6); // $ExpectType number +numeric["||"](2, 3, vector); // $ExpectType number[] +numeric["||"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.orVV(vector, vector); // $ExpectType number[] +numeric.orSV(2, vector); // $ExpectType number[] +numeric.orVS(vector, 2); // $ExpectType number[] +numeric.oreq(vector, 3); // $ExpectType number[] +numeric.oreqV(vector, vector); // $ExpectType number[] +numeric.oreqS(vector, 3); // $ExpectType number[] + +numeric.eq(2, 5); // $ExpectType boolean +numeric.eq(2, vector); // $ExpectType boolean[] +numeric.eq(threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric["==="](2, 5); // $ExpectType boolean +numeric["==="](2, vector); // $ExpectType boolean[] +numeric["==="](threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.eqVV(vector, vector); // $ExpectType boolean[] +numeric.eqSV(2, vector); // $ExpectType boolean[] +numeric.eqVS(vector, 2); // $ExpectType boolean[] +numeric.eqeq(vector, 3); // $ExpectType boolean[] +numeric.eqeqV(vector, vector); // $ExpectType boolean[] +numeric.eqeqS(vector, 3); // $ExpectType boolean[] + +numeric.neq(2, 5); // $ExpectType boolean +numeric.neq(2, vector); // $ExpectType boolean[] +numeric.neq(threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric["==="](2, 5); // $ExpectType boolean +numeric["==="](2, vector); // $ExpectType boolean[] +numeric["==="](threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.neqVV(vector, vector); // $ExpectType boolean[] +numeric.neqSV(2, vector); // $ExpectType boolean[] +numeric.neqVS(vector, 2); // $ExpectType boolean[] +numeric.neqeq(vector, 3); // $ExpectType boolean[] +numeric.neqeqV(vector, vector); // $ExpectType boolean[] +numeric.neqeqS(vector, 3); // $ExpectType boolean[] + +numeric.lt(2, 5); // $ExpectType boolean +numeric.lt(2, vector); // $ExpectType boolean[] +numeric.lt(threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric["==="](2, 5); // $ExpectType boolean +numeric["==="](2, vector); // $ExpectType boolean[] +numeric["==="](threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.ltVV(vector, vector); // $ExpectType boolean[] +numeric.ltSV(2, vector); // $ExpectType boolean[] +numeric.ltVS(vector, 2); // $ExpectType boolean[] +numeric.lteq(vector, 3); // $ExpectType boolean[] +numeric.lteqV(vector, vector); // $ExpectType boolean[] +numeric.lteqS(vector, 3); // $ExpectType boolean[] + +numeric.gt(2, 5); // $ExpectType boolean +numeric.gt(2, vector); // $ExpectType boolean[] +numeric.gt(threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric["==="](2, 5); // $ExpectType boolean +numeric["==="](2, vector); // $ExpectType boolean[] +numeric["==="](threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.gtVV(vector, vector); // $ExpectType boolean[] +numeric.gtSV(2, vector); // $ExpectType boolean[] +numeric.gtVS(vector, 2); // $ExpectType boolean[] +numeric.gteq(vector, 3); // $ExpectType boolean[] +numeric.gteqV(vector, vector); // $ExpectType boolean[] +numeric.gteqS(vector, 3); // $ExpectType boolean[] + +numeric.leq(2, 5); // $ExpectType boolean +numeric.leq(2, vector); // $ExpectType boolean[] +numeric.leq(threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric["==="](2, 5); // $ExpectType boolean +numeric["==="](2, vector); // $ExpectType boolean[] +numeric["==="](threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.leqVV(vector, vector); // $ExpectType boolean[] +numeric.leqSV(2, vector); // $ExpectType boolean[] +numeric.leqVS(vector, 2); // $ExpectType boolean[] +numeric.leqeq(vector, 3); // $ExpectType boolean[] +numeric.leqeqV(vector, vector); // $ExpectType boolean[] +numeric.leqeqS(vector, 3); // $ExpectType boolean[] + +numeric.geq(2, 5); // $ExpectType boolean +numeric.geq(2, vector); // $ExpectType boolean[] +numeric.geq(threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric["==="](2, 5); // $ExpectType boolean +numeric["==="](2, vector); // $ExpectType boolean[] +numeric["==="](threeDimensionalMatrix, threeDimensionalMatrix); // $ExpectType MultidimensionalArray +numeric.geqVV(vector, vector); // $ExpectType boolean[] +numeric.geqSV(2, vector); // $ExpectType boolean[] +numeric.geqVS(vector, 2); // $ExpectType boolean[] +numeric.geqeq(vector, 3); // $ExpectType boolean[] +numeric.geqeqV(vector, vector); // $ExpectType boolean[] +numeric.geqeqS(vector, 3); // $ExpectType boolean[] + +numeric.band(2, 5, 6); // $ExpectType number +numeric.band(2, 3, vector); // $ExpectType number[] +numeric.band(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["&"](2, 5, 6); // $ExpectType number +numeric["&"](2, 3, vector); // $ExpectType number[] +numeric["&"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.bandVV(vector, vector); // $ExpectType number[] +numeric.bandSV(2, vector); // $ExpectType number[] +numeric.bandVS(vector, 2); // $ExpectType number[] +numeric.bandeq(vector, 3); // $ExpectType number[] +numeric.bandeqV(vector, vector); // $ExpectType number[] +numeric.bandeqS(vector, 3); // $ExpectType number[] + +numeric.bor(2, 5, 6); // $ExpectType number +numeric.bor(2, 3, vector); // $ExpectType number[] +numeric.bor(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["|"](2, 5, 6); // $ExpectType number +numeric["|"](2, 3, vector); // $ExpectType number[] +numeric["|"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.borVV(vector, vector); // $ExpectType number[] +numeric.borSV(2, vector); // $ExpectType number[] +numeric.borVS(vector, 2); // $ExpectType number[] +numeric.boreq(vector, 3); // $ExpectType number[] +numeric.boreqV(vector, vector); // $ExpectType number[] +numeric.boreqS(vector, 3); // $ExpectType number[] + +numeric.bxor(2, 5, 6); // $ExpectType number +numeric.bxor(2, 3, vector); // $ExpectType number[] +numeric.bxor(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["^"](2, 5, 6); // $ExpectType number +numeric["^"](2, 3, vector); // $ExpectType number[] +numeric["^"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.bxorVV(vector, vector); // $ExpectType number[] +numeric.bxorSV(2, vector); // $ExpectType number[] +numeric.bxorVS(vector, 2); // $ExpectType number[] +numeric.bxoreq(vector, 3); // $ExpectType number[] +numeric.bxoreqV(vector, vector); // $ExpectType number[] +numeric.bxoreqS(vector, 3); // $ExpectType number[] + +numeric.lshift(2, 5, 6); // $ExpectType number +numeric.lshift(2, 3, vector); // $ExpectType number[] +numeric.lshift(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric["<<"](2, 5, 6); // $ExpectType number +numeric["<<"](2, 3, vector); // $ExpectType number[] +numeric["<<"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.lshiftVV(vector, vector); // $ExpectType number[] +numeric.lshiftSV(2, vector); // $ExpectType number[] +numeric.lshiftVS(vector, 2); // $ExpectType number[] +numeric.lshifteq(vector, 3); // $ExpectType number[] +numeric.lshifteqV(vector, vector); // $ExpectType number[] +numeric.lshifteqS(vector, 3); // $ExpectType number[] + +numeric.rshift(2, 5, 6); // $ExpectType number +numeric.rshift(2, 3, vector); // $ExpectType number[] +numeric.rshift(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric[">>"](2, 5, 6); // $ExpectType number +numeric[">>"](2, 3, vector); // $ExpectType number[] +numeric[">>"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.rshiftVV(vector, vector); // $ExpectType number[] +numeric.rshiftSV(2, vector); // $ExpectType number[] +numeric.rshiftVS(vector, 2); // $ExpectType number[] +numeric.rshifteq(vector, 3); // $ExpectType number[] +numeric.rshifteqV(vector, vector); // $ExpectType number[] +numeric.rshifteqS(vector, 3); // $ExpectType number[] + +numeric.rrshift(2, 5, 6); // $ExpectType number +numeric.rrshift(2, 3, vector); // $ExpectType number[] +numeric.rrshift(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric[">>>"](2, 5, 6); // $ExpectType number +numeric[">>>"](2, 3, vector); // $ExpectType number[] +numeric[">>>"](threeDimensionalMatrix, 2, 4); // $ExpectType number[][][] +numeric.rrshiftVV(vector, vector); // $ExpectType number[] +numeric.rrshiftSV(2, vector); // $ExpectType number[] +numeric.rrshiftVS(vector, 2); // $ExpectType number[] +numeric.rrshifteq(vector, 3); // $ExpectType number[] +numeric.rrshifteqV(vector, vector); // $ExpectType number[] +numeric.rrshifteqS(vector, 3); // $ExpectType number[] + +numeric.atan2(2, 5, 6); // $ExpectType number +numeric.atan2(2, 3, vector); // $ExpectType number[] +numeric.atan2(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric.atan2VV(vector, vector); // $ExpectType number[] +numeric.atan2SV(2, vector); // $ExpectType number[] +numeric.atan2VS(vector, 2); // $ExpectType number[] +numeric.atan2eq(vector, 3); // $ExpectType number[] +numeric.atan2eqV(vector, vector); // $ExpectType number[] +numeric.atan2eqS(vector, 3); // $ExpectType number[] + +numeric.pow(2, 5, 6); // $ExpectType number +numeric.pow(2, 3, vector); // $ExpectType number[] +numeric.pow(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric.powVV(vector, vector); // $ExpectType number[] +numeric.powSV(2, vector); // $ExpectType number[] +numeric.powVS(vector, 2); // $ExpectType number[] +numeric.poweq(vector, 3); // $ExpectType number[] +numeric.poweqV(vector, vector); // $ExpectType number[] +numeric.poweqS(vector, 3); // $ExpectType number[] + +numeric.max(2, 5, 6); // $ExpectType number +numeric.max(2, 3, vector); // $ExpectType number[] +numeric.max(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric.maxVV(vector, vector); // $ExpectType number[] +numeric.maxSV(2, vector); // $ExpectType number[] +numeric.maxVS(vector, 2); // $ExpectType number[] +numeric.maxeq(vector, 3); // $ExpectType number[] +numeric.maxeqV(vector, vector); // $ExpectType number[] +numeric.maxeqS(vector, 3); // $ExpectType number[] + +numeric.min(2, 5, 6); // $ExpectType number +numeric.min(2, 3, vector); // $ExpectType number[] +numeric.min(threeDimensionalMatrix, 2, threeDimensionalMatrix); // $ExpectType number[][][] +numeric.minVV(vector, vector); // $ExpectType number[] +numeric.minSV(2, vector); // $ExpectType number[] +numeric.minVS(vector, 2); // $ExpectType number[] +numeric.mineq(vector, 3); // $ExpectType number[] +numeric.mineqV(vector, vector); // $ExpectType number[] +numeric.mineqS(vector, 3); // $ExpectType number[] + +numeric.any(23); // $ExpectType boolean +numeric.anyV(vector); // $ExpectType boolean + +numeric.all(23); // $ExpectType boolean +numeric.allV(vector); // $ExpectType boolean + +numeric.sum(threeDimensionalMatrix); // $ExpectType number +numeric.sumV(vector); // $ExceptType number + +numeric.prod(threeDimensionalMatrix); // $ExpectType number +numeric.prodV(vector); // $ExceptType number + +numeric.norm2Squared(threeDimensionalMatrix); // $ExpectType number +numeric.norm2SquaredV(vector); // $ExceptType number + +numeric.norminf(threeDimensionalMatrix); // $ExpectType number +numeric.norminfV(vector); // $ExceptType number + +numeric.norm1(threeDimensionalMatrix); // $ExpectType number +numeric.norm1V(vector); // $ExceptType number + +numeric.sup(threeDimensionalMatrix); // $ExpectType number +numeric.supV(vector); // $ExceptType number + +numeric.inf(threeDimensionalMatrix); // $ExpectType number +numeric.infV(vector); // $ExceptType number + +numeric.trunc(vector, 3); // $ExpectType number[] +numeric.truncVV(vector, vector); // $ExpectType number[] +numeric.truncVS(vector, 4); // $ExpectType number[] +numeric.truncSV(3, vector); // $ExpectType number[] + +numeric.inv(matrix); // $ExpectType number[][] +numeric.det(matrix); // $ExpectType number +numeric.transpose(matrix); // $ExpectType number[][] +numeric.negtranspose(matrix); // $ExpectType number[][] +numeric.random(vector); // $ExpectType NonScalar +numeric.norm2(threeDimensionalMatrix); // $ExpectType number +numeric.linspace(1, 3, 5); // $ExpectType number[] +numeric.getBlock(threeDimensionalMatrix, vector, vector); // $ExpectType number[][][] +const block: number[][][] = numeric.setBlock( + threeDimensionalMatrix, + vector, + vector, + threeDimensionalMatrix +); +numeric.blockMatrix(matrix); // $ExpectType number[][] +numeric.tensor(3, 5); // $ExpectType number +numeric.tensor(vector, vector); // $ExpectType number[][] + +const tensor = numeric.t(vector, vector); +tensor + .add(tensor) + .sub(tensor) + .mul(tensor) + .reciprocal() + .div(tensor) + .dot(tensor) + .transpose() + .transjugate() + .exp() + .conj() + .neg() + .sin() + .cos() + .abs() + .log() + .norm2() + .inv() + .get(vector) + .set(vector, tensor) + .getRow(2) + .setRow(2, tensor) + .getRows(10, 10) + .setRows(10, 10, tensor) + .getBlock(vector, vector) + .setBlock(vector, vector, tensor) + .rep(vector, tensor) + .diag(tensor) + .identity(3) + .getDiag() + .fft() + .ifft() + .eig(); + +numeric.house(vector); // $ExpectType number[] +numeric.toUpperHessenberg(matrix); // $ExpectType { H: number[][]; Q: number[][]; } +numeric.QRFrancis(matrix, 25); // $ExpectType { Q: number[][]; B: number[][]; } +numeric.eig(matrix); // $ExpectType { lambda: Tensor; E: Tensor; } + +numeric.ccsSparse(matrix); // $ExpectType [number[], number[], number[]] +numeric.ccsFull(sparseMatrix); // $ExpectType number[][] +numeric.ccsTSolve(sparseMatrix, vector, vector, vector, vector); // $ExpectType number[] +numeric.ccsDot(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +const lup = numeric.ccsLUP(sparseMatrix, 4); +numeric.ccsDim(sparseMatrix); // $ExpectType number[] +numeric.ccsGetBlock(sparseMatrix, vector, 3); // $ExpectType [number[], number[], number[]] +numeric.ccsLUPSolve(lup, sparseMatrix); // $ExpectType number[] +numeric.ccsScatter(sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsGather(sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsadd(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsadd(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsaddMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccssub(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccssub(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccssubMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsmul(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsmul(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsmulMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsdiv(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsdiv(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsdivMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsmod(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsmod(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsmodMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsand(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsand(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsandMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsor(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsor(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsorMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccseq(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccseq(2, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccseqMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] + +numeric.ccsneq(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsneq(2, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsneqMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] + +numeric.ccslt(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccslt(2, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsltMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] + +numeric.ccsgt(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsgt(2, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsgtMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] + +numeric.ccsleq(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsleq(2, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsleqMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] + +numeric.ccsgeq(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsgeq(2, sparseMatrix); // $ExpectType [number[], number[], boolean[]] +numeric.ccsgeqMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], boolean[]] + +numeric.ccsband(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsband(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsbandMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsbor(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsbor(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsborMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsbxor(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsbxor(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsbxorMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccslshift(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccslshift(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccslshiftMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsrshift(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsrshift(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsrshiftMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +numeric.ccsrrshift(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsrrshift(2, sparseMatrix); // $ExpectType [number[], number[], number[]] +numeric.ccsrrshiftMM(sparseMatrix, sparseMatrix); // $ExpectType [number[], number[], number[]] + +const lu = numeric.cLU(matrix); +numeric.cLUSolve(lu, vector); // $ExpectType number[] +numeric.cgrid(2, "L"); // $ExpectType number[][] +numeric.cdelsq(matrix); // $ExpectType number[][] +numeric.cdotmv(matrix, vector); // $ExpectType number[] + +const spline = numeric.spline(vector, matrix, "periodic", 3); +spline.diff().roots(); // $ExpectType number[] +spline.at(vector); // $ExpectType number | number[] + +numeric.uncmin((x: number[]) => 23, vector, 2, null, 3, () => undefined, { + Hinv: matrix +}); +numeric.gradient((x: number[]) => 44, vector); // $ExpectType number[] + +const dopri = numeric.dopri( + 1, + 1, + 1, + (x = 23, y = 44) => 44, + 2, + 3, + (x = 23, y = 44) => 44 +); +dopri.at(vector); // $ExpectType number[] | number[][] + +numeric.echelonize(matrix); // $ExpectType { I: number[][]; A: number[][]; P: number[]; } +numeric.solveLP(vector, matrix, vector, matrix, matrix, 3, 4); // $ExpectType { solution: number | number[]; message: string; iterations: number; } + +numeric.solveQP(matrix, vector, matrix, vector, 3, 44); // $ExpectType { solution: number[]; value: number[]; unconstrained_solution: number[]; iterations: number[]; iact: number[]; message: string; } + +numeric.svd(matrix); // $ExpectType { U: number[][]; S: number[]; V: number[][]; } diff --git a/types/numeric/tsconfig.json b/types/numeric/tsconfig.json new file mode 100644 index 0000000000..797af40d6b --- /dev/null +++ b/types/numeric/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es5" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "numeric-tests.ts" + ] +} diff --git a/types/numeric/tslint.json b/types/numeric/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/numeric/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}