Skip to content

Commit

Permalink
feat: Implement multiplying chains of matrices using dynamic programm…
Browse files Browse the repository at this point in the history
…ing (#141)
  • Loading branch information
jbrown1618 authored Jul 11, 2021
1 parent aef543b commit ffdc77f
Show file tree
Hide file tree
Showing 13 changed files with 1,453 additions and 2,469 deletions.
5 changes: 4 additions & 1 deletion docs/VECTOR.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ export function center<S>(A: Matrix<S>): Matrix<S>;
// @public
export function centralDifferenceMatrix(binCount: number): NumberMatrix;

// @public
export function chainProduct<S>(...matrices: Matrix<S>[]): Matrix<S>;

// @public
export interface CholeskyDecomposition<S> {
// (undocumented)
Expand Down Expand Up @@ -373,7 +376,7 @@ export function isOrthonormal<S>(matrix: Matrix<S>): boolean;
export function isSparse<S>(vector: Vector<S>): vector is SparseVector<S>;

// @public
export function isSquare(matrix: Matrix<any>): boolean;
export function isSquare<S>(matrix: Matrix<S>): boolean;

// @public
export function isSymmetric<S>(matrix: Matrix<S>): boolean;
Expand Down
28 changes: 28 additions & 0 deletions docs/api/vector.chainproduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@josh-brown/vector](./vector.md) &gt; [chainProduct](./vector.chainproduct.md)

## chainProduct() function

Returns the product of the given array of matrices.

<b>Signature:</b>

```typescript
export declare function chainProduct<S>(...matrices: Matrix<S>[]): Matrix<S>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| matrices | [Matrix](./vector.matrix.md)<!-- -->&lt;S&gt;\[\] | The array of matrices to multiply |

<b>Returns:</b>

[Matrix](./vector.matrix.md)<!-- -->&lt;S&gt;

## Remarks

Uses dynamic programming to determine the order of multiplication that minimizes the total number of scalar multiplications.

4 changes: 2 additions & 2 deletions docs/api/vector.issquare.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Tests if a matrix is square.
<b>Signature:</b>

```typescript
export declare function isSquare(matrix: Matrix<any>): boolean;
export declare function isSquare<S>(matrix: Matrix<S>): boolean;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| matrix | [Matrix](./vector.matrix.md)<!-- -->&lt;any&gt; | The matrix to check |
| matrix | [Matrix](./vector.matrix.md)<!-- -->&lt;S&gt; | The matrix to check |

<b>Returns:</b>

Expand Down
1 change: 1 addition & 0 deletions docs/api/vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
| [center(x)](./vector.center.md) | Returns the vector <code>x</code>, shifted so that its mean is at 0 |
| [center(A)](./vector.center_1.md) | Returns the matrix <code>A</code> with each column shifted so that its mean is at 0 |
| [centralDifferenceMatrix(binCount)](./vector.centraldifferencematrix.md) | Builds a matrix that transforms a vector to a vector of central differences |
| [chainProduct(matrices)](./vector.chainproduct.md) | Returns the product of the given array of matrices. |
| [columnSumSupremumNorm(A)](./vector.columnsumsupremumnorm.md) | Calculates the 1-Norm of a matrix <code>A</code> |
| [correlation(first, second)](./vector.correlation.md) | Calculates the correlation coefficient r of two vectors |
| [correlation(A)](./vector.correlation_1.md) | Calculates the correlation matrix of a matrix <code>A</code> |
Expand Down
Loading

0 comments on commit ffdc77f

Please sign in to comment.