<commit_before>Matrix Function
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]

> Applies a function to each [matrix](https://github.com/dstructs/matrix) element.


## Installation

``` bash
$ npm install compute-matrix-function
```

For use in the browser, use [browserify](https://github.com/substack/node-browserify).


## Usage

``` javascript
var matrixfun = require( 'compute-matrix-function' );
```

<a name="matrixfun"></a>
#### matrixfun( fcn, ...matrix[, options] )

Applies a `function` to each [`matrix`](https://github.com/dstructs/matrix) element.

``` javascript
var matrix = require( 'dstructs-matrix' );

var mat = matrix( [5,5], 'int8' );
/*
    [ 0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0 ]
*/

function add5( val ) {
	return val + 5;
}

var out = matrixfun( add5, mat );
/*
    [ 5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5 ]
*/
```

The function accepts the following `options`:

*	__dtype__: output data type. Default: `float64`.
*	__output__: `boolean` indicating whether an output [`matrix`](https://github.com/dstructs/matrix) has been provided. Default: `false`.

By default, the output [`matrix`](https://github.com/dstructs/matrix) data type is `float64` in order to preserve precision. To specify a different data type, set the `dtype` option (see [`matrix`](https://github.com/dstructs/matrix) for a list of acceptable data types).

``` javascript
var out = matrixfun( add, mat, {
	'dtype': 'int8';
});
/*
    [ 5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5 ]
*/
var dtype = out.dtype;
// returns 'int8'
```

By default, the `function` returns a new [`matrix`](https://github.com/dstructs/matrix). To mutate a [`matrix`](https://github.com/dstructs/matrix) (e.g., when input values can be discarded or when optimizing memory usage), set the `output` option to `true` to indicate that an output [`matrix`](https://github.com/dstructs/matrix) has been provided as the __first__ [`matrix`](https://github.com/dstructs/matrix) argument.

``` javascript
var out = matrix( [5,5], 'int8' );
/*
    [ 0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0 ]
*/

matrixfun( add, out, mat, {
	'output': 'true';
});
/*
      [ 5 5 5 5 5
        5 5 5 5 5
out =   5 5 5 5 5
        5 5 5 5 5
        5 5 5 5 5 ]
*/
```

===
### Factory

The main exported `function` does __not__ make any assumptions regarding the number of input [`matrices`](https://github.com/dstructs/matrix). To create a reusable [`matrix`](https://github.com/dstructs/matrix) function where the number of input [`matrices`](https://github.com/dstructs/matrix) is known, a factory method is provided.


<a name="matrixfun-factory"></a>
#### matrixfun.factory( [fcn,] num[, options] )

Creates an apply `function` to apply a `function` to each [`matrix`](https://github.com/dstructs/matrix) element.

``` javascript
var mfun = matrixfun.factory( 2 );

function add( x, y ) {
	return x + y;
}

var mat1 = matrix( [5,5], 'int8' ),
	mat2 = matrix( [5,5], 'int8' );

for ( var i = 0; i < 5; i++ ) {
	for ( var j = 0; j < 5; j++ ) {
		mat1.set( i, j, 5 );
		mat2.set( i, j, i*5 + j );
	}
}
/*
       [ 5 5 5 5 5
         5 5 5 5 5
mat1 =   5 5 5 5 5
         5 5 5 5 5
         5 5 5 5 5 ]

       [  0  1  2  3  4
          5  6  7  8  9
mat2 =   10 11 12 13 14
         15 16 17 18 19
         20 21 22 23 24 ]
*/

var out = mfun( add, mat1, mat2 );
/*
    [  5  6  7  8  9
      10 11 12 13 14
      15 16 17 18 19
      20 21 22 23 24
      25 26 27 28 29 ]
*/
```

The function accepts the following `options`:

*	__dtype__: output data type. Default: `float64`.

An apply `function` may be provided during `function` creation.

``` javascript
var madd = matrixfun.factory( add, 2 );

var out = madd( mat1, mat2 );
/*
    [  5  6  7  8  9
      10 11 12 13 14
      15 16 17 18 19
      20 21 22 23 24
      25 26 27 28 29 ]
*/
```

__Note__: a factory `function` __always__ returns a new [`matrix`](https://github.com/dstructs/matrix).


===<commit_msg>[UPDATE] README.<commit_after>Matrix Function
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]

> Applies a function to each [matrix](https://github.com/dstructs/matrix) element.


## Installation

``` bash
$ npm install compute-matrix-function
```

For use in the browser, use [browserify](https://github.com/substack/node-browserify).


## Usage

``` javascript
var matrixfun = require( 'compute-matrix-function' );
```

<a name="matrixfun"></a>
#### matrixfun( fcn, ...matrix[, options] )

Applies a `function` to each [`matrix`](https://github.com/dstructs/matrix) element.

``` javascript
var matrix = require( 'dstructs-matrix' );

var mat = matrix( [5,5], 'int8' );
/*
    [ 0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0 ]
*/

function add5( val ) {
	return val + 5;
}

var out = matrixfun( add5, mat );
/*
    [ 5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5 ]
*/
```

The function accepts the following `options`:

*	__dtype__: output data type. Default: `float64`.
*	__output__: `boolean` indicating whether an output [`matrix`](https://github.com/dstructs/matrix) has been provided. Default: `false`.

By default, the output [`matrix`](https://github.com/dstructs/matrix) data type is `float64` in order to preserve precision. To specify a different data type, set the `dtype` option (see [`matrix`](https://github.com/dstructs/matrix) for a list of acceptable data types).

``` javascript
var out = matrixfun( add5, mat, {
	'dtype': 'int8';
});
/*
    [ 5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5
      5 5 5 5 5 ]
*/
var dtype = out.dtype;
// returns 'int8'
```

By default, the `function` returns a new [`matrix`](https://github.com/dstructs/matrix). To mutate a [`matrix`](https://github.com/dstructs/matrix) (e.g., when input values can be discarded or when optimizing memory usage), set the `output` option to `true` to indicate that an output [`matrix`](https://github.com/dstructs/matrix) has been provided as the __first__ [`matrix`](https://github.com/dstructs/matrix) argument.

``` javascript
var out = matrix( [5,5], 'int8' );
/*
    [ 0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0
      0 0 0 0 0 ]
*/

matrixfun( add5, out, mat, {
	'output': 'true';
});
/*
      [ 5 5 5 5 5
        5 5 5 5 5
out =   5 5 5 5 5
        5 5 5 5 5
        5 5 5 5 5 ]
*/
```

===
### Factory

The main exported `function` does __not__ make any assumptions regarding the number of input [`matrices`](https://github.com/dstructs/matrix). To create a reusable [`matrix`](https://github.com/dstructs/matrix) function where the number of input [`matrices`](https://github.com/dstructs/matrix) is known, a factory method is provided.


<a name="matrixfun-factory"></a>
#### matrixfun.factory( [fcn,] num[, options] )

Creates an apply `function` to apply a `function` to each [`matrix`](https://github.com/dstructs/matrix) element.

``` javascript
var mfun = matrixfun.factory( 2 );

function add( x, y ) {
	return x + y;
}

var mat1 = matrix( [5,5], 'int8' ),
	mat2 = matrix( [5,5], 'int8' );

for ( var i = 0; i < 5; i++ ) {
	for ( var j = 0; j < 5; j++ ) {
		mat1.set( i, j, 5 );
		mat2.set( i, j, i*5 + j );
	}
}
/*
       [ 5 5 5 5 5
         5 5 5 5 5
mat1 =   5 5 5 5 5
         5 5 5 5 5
         5 5 5 5 5 ]

       [  0  1  2  3  4
          5  6  7  8  9
mat2 =   10 11 12 13 14
         15 16 17 18 19
         20 21 22 23 24 ]
*/

var out = mfun( add, mat1, mat2 );
/*
    [  5  6  7  8  9
      10 11 12 13 14
      15 16 17 18 19
      20 21 22 23 24
      25 26 27 28 29 ]
*/
```

An apply `function` may be provided during `function` creation.

``` javascript
var madd = matrixfun.factory( add, 2 );

var out = madd( mat1, mat2 );
/*
    [  5  6  7  8  9
      10 11 12 13 14
      15 16 17 18 19
      20 21 22 23 24
      25 26 27 28 29 ]
*/
```

The function accepts the following `options`:

*	__dtype__: output data type. Default: `float64`.

By default, the output [`matrix`](https://github.com/dstructs/matrix) data type is `float64` any time a function is applied. To specify a different data type, set the `dtype` option.

``` javascript
var madd = matrixfun.factory( add, 2, {
	'dtype': 'int32';
});

var out = madd( mat1, mat2 );
/*
    [  5  6  7  8  9
      10 11 12 13 14
      15 16 17 18 19
      20 21 22 23 24
      25 26 27 28 29 ]
*/

var dtype = out.dtype;
// returns 'int32'

// ...and for all subsequent calls...
out = madd( mat1, mat2 );
dtype = out.dtype;
// returns 'int32'
```

__Note__: a factory `function` __always__ returns a new [`matrix`](https://github.com/dstructs/matrix).


===
{'fraction_non_alphanumeric': 0.14886008046490837, 'fraction_numerical': 0.07845328565042467, 'mean_word_length': 2.586773547094188, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 31, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5337262', 'n_tokens_mistral': 3757, 'n_tokens_neox': 3152, 'n_words': 1214}