Skip to content

Commit

Permalink
fix: typings from refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisseau committed Nov 29, 2023
1 parent 8457dda commit 48164c2
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions matrix.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,24 @@ export abstract class AbstractMatrix {
* This is equivalent to calling the Matrix constructor.
* @param rows - Number of rows.
* @param columns - Number of columns.
* @template _M is private. Don't override it.
* @returns The new matrix.
*/
static zeros(rows: number, columns: number): Matrix;
static zeros<_M extends AbstractMatrix = Matrix>(
rows: number,
columns: number,
): _M;

/**
* Creates a matrix with the given dimensions. Values will be set to one.
* @param rows - Number of rows.
* @param columns - Number of columns.
* @returns The new matrix.
*/
static ones(rows: number, columns: number): Matrix;
static ones<M extends AbstractMatrix = Matrix>(
rows: number,
columns: number,
): M;

/**
* Creates a matrix with the given dimensions. Values will be randomly set.
Expand Down Expand Up @@ -1009,28 +1016,11 @@ export class Matrix extends AbstractMatrix {

export default Matrix;

export class SymmetricMatrix extends Matrix {
/**
* Creates a symmetric matrix with the given dimensions. Values will be set to zero.
* This is equivalent to calling the Matrix constructor.
* @param diagonalSize - Number of rows or columns (square).
* @returns The new symmetric matrix.
*/
static zeros(diagonalSize: number): SymmetricMatrix;

/**
* Creates a symmetric matrix with the given dimensions. Values will be set to one.
* @param diagonalSize - Number of rows or columns (square).
* @returns The new symmetric matrix.
*/
static ones(diagonalSize: number): SymmetricMatrix;

static isSymmetricMatrix(value: unknown): value is SymmetricMatrix;

export class SymmetricMatrix extends AbstractMatrix {
/**
* alias for `rows` or `columns` (square matrix so equals)
*/
get diagonalSize(): number;
readonly diagonalSize: number;

/**
* @throws TypeError if otherMatrix is not symmetric
Expand All @@ -1044,6 +1034,32 @@ export class SymmetricMatrix extends Matrix {
*/
constructor(data: ArrayLike<ArrayLike<number>>);

get(rowIndex: number, columnIndex: number): number;
set(rowIndex: number, columnIndex: number, value: number): this;

/**
* Creates a symmetric matrix with the given dimensions. Values will be set to zero.
* This is equivalent to calling the Matrix constructor.
*
* @param diagonalSize - Number of rows or columns (square).
* @template _M is private, do not override it.
* @returns The new symmetric matrix.
*/
static zeros<_M extends AbstractMatrix = SymmetricMatrix>(
diagonalSize: number,
): _M;
/**
* Creates a symmetric matrix with the given dimensions. Values will be set to one.
* @param diagonalSize - Number of rows or columns (square).
* @template _M is private, do not override it.
* @returns The new symmetric matrix.
*/
static ones<_M extends AbstractMatrix = SymmetricMatrix>(
diagonalSize: number,
): _M;

static isSymmetricMatrix(value: unknown): value is SymmetricMatrix;

/**
* copy to a new matrix
*/
Expand Down Expand Up @@ -1141,14 +1157,14 @@ export class DistanceMatrix extends SymmetricMatrix {
* @param sidesSize - Number of rows or columns (square).
* @returns The new symmetric matrix.
*/
static zeros(sidesSize: number): DistanceMatrix;
static zeros<M extends AbstractMatrix = DistanceMatrix>(sidesSize: number): M;

/**
* Creates a symmetric matrix with the given dimensions. Values will be set to one.
* @param sidesSize - Number of rows or columns (square).
* @returns The new symmetric matrix.
*/
static ones(sidesSize: number): DistanceMatrix;
static ones<M extends AbstractMatrix = DistanceMatrix>(sidesSize: number): M;

static isDistanceMatrix(value: unknown): value is DistanceMatrix;

Expand Down

0 comments on commit 48164c2

Please sign in to comment.