# Class: Matrix

## Matrix()

#### new Matrix()

MaiaScript matrix library.

Source:
  - Matrix.js, line 24

### Methods

#### avg(mtx, r1, c1, r2, c2) → {number}

Returns the mean and standard deviation of the values contained in a matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 43

##### Returns:

Mean and standard deviation of the values contained in a matrix.

Type
  number

#### count(mtx, r1, c1, r2, c2) → {number}

Returns the number of non-zero elements in the matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 122

##### Returns:

The number of non-zero elements in the matrix.

Type
  number

#### cross(a, b) → {array}

Calculates the cross product of two vectors A and B.

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | object | The matrix A.
`b` | object | The matrix B.

Source:
  - Matrix.js, line 186

##### Returns:

A (rows x columns) matrix.

Type
  array

#### dot(a, b) → {array}

Calculates the dot product of two vectors A and B.

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | object | The matrix A.
`b` | object | The matrix B.

Source:
  - Matrix.js, line 218

##### Returns:

A (rows x columns) matrix.

Type
  array

#### max(mtx, r1, c1, r2, c2) → {number}

Returns the largest value in an array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 249

##### Returns:

The smallest value in an array.

Type
  number

#### min(mtx, r1, c1, r2, c2) → {number}

Returns the smallest value in an array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 324

##### Returns:

The smallest value in an array.

Type
  number

#### sum(mtx, r1, c1, r2, c2) → {number}

Calculates the sum of all cells in the matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 398

##### Returns:

Sum of the values contained in a matrix.

Type
  number

#### sum2(mtx, r1, c1, r2, c2) → {number}

Calculates the squared sum of all cells in the matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 463

##### Returns:

Sum of the values contained in a matrix.

Type
  number

#### trans(mtx, r1, c1, r2, c2) → {number}

Returns the transpose of an array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix.
`r1` | number | First row.
`c1` | number | First column.
`r2` | number | Last row.
`c2` | number | Last column.

Source:
  - Matrix.js, line 528

##### Returns:

The transpose of an array.

Type
  number

#### triang(mtx) → {array}

Calculates the triangular equivalent matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mtx` | object | The matrix to calculate the triangular equivalent matrix.

Source:
  - Matrix.js, line 571

##### Returns:

A (rows x columns) matrix.

Type
  array

#### (inner) init()

Creates the attributes of the class.

Source:
  - Matrix.js, line 30