node-nlp
Version:
Library for NLU (Natural Language Understanding) done in Node.js
2,756 lines (726 loc) • 31.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Matrix</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Matrix</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Matrix<span class="signature">(elements, useClone)</span><span class="type-signature"></span></h2>
<div class="class-description">Class representing a Matrix and some of the possible operations.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Matrix"><span class="type-signature"></span>new Matrix<span class="signature">(elements, useClone)</span><span class="type-signature"></span></h4>
<div class="description">
Constructor of the class
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>elements</code></td>
<td class="type">
<span class="param-type">Array.<Array.<Number>></span>
|
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</td>
<td class="default">
</td>
<td class="description last">Elements for initializing the matrix.</td>
</tr>
<tr>
<td class="name"><code>useClone</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="default">
true
</td>
<td class="description last">If true, the input array is cloned. If false, it uses
the elements input directly by reference.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line29">line 29</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".fill"><span class="type-signature">(static) </span>fill<span class="signature">(n, m, v)</span><span class="type-signature"> → {Array.<Array.<Number>>|<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Creates a new Matrix with given dimensions and filled with the cell value.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Amount of rows.</td>
</tr>
<tr>
<td class="name"><code>m</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Amount of columns.</td>
</tr>
<tr>
<td class="name"><code>v</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Cell value.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line112">line 112</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Matrix with given dimensions and cell value.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Array.<Number>></span>
|
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id=".one"><span class="type-signature">(static) </span>one<span class="signature">(n, m)</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Creates a new Matrix with given dimensions and filled with 1.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Amount of rows.</td>
</tr>
<tr>
<td class="name"><code>m</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Amount of columns.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line136">line 136</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Matrix with given dimensions filled with 1.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id=".zero"><span class="type-signature">(static) </span>zero<span class="signature">(n, m)</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Creates a new Matrix with given dimensions and filled with 0.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Amount of rows.</td>
</tr>
<tr>
<td class="name"><code>m</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Amount of columns.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line126">line 126</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Matrix with given dimensions filled with 0.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id="augment"><span class="type-signature"></span>augment<span class="signature">(matrix)</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Return a matrix where is row is augmented with the corresponding
row of the input matrix.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matrix</code></td>
<td class="type">
<span class="param-type">Array.<Array.<Number>></span>
|
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</td>
<td class="description last">Input matrix.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line192">line 192</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Matrix that is this one augmented with the input one.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id="column"><span class="type-signature"></span>column<span class="signature">(j)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Return a column of the matrix as a vector.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>j</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Column number.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line86">line 86</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Column of the matrix as a vector.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="isSameColumnToRowSize"><span class="type-signature"></span>isSameColumnToRowSize<span class="signature">(matrix)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Indicates if another matrix has exactly same amount of rows as this
matrix amount of columns.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matrix</code></td>
<td class="type">
<span class="param-type">Array.<Array.<Number>></span>
|
<span class="param-type">Array.<Number></span>
|
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
|
<span class="param-type"><a href="Vector.html">Vector</a></span>
</td>
<td class="description last">Input matrix.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line236">line 236</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if this one column count equals input row count.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="isSameSizeAs"><span class="type-signature"></span>isSameSizeAs<span class="signature">(matrix)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Indicates if another matrix has exactly same dimensions as this one.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matrix</code></td>
<td class="type">
<span class="param-type">Array.<Array.<Number>></span>
|
<span class="param-type">Array.<Number></span>
|
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
|
<span class="param-type"><a href="Vector.html">Vector</a></span>
</td>
<td class="description last">Input matrix.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line219">line 219</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if both have same number of rows and columns.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="log"><span class="type-signature"></span>log<span class="signature">()</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Returns a new matrix where each cell is the natural logarithm
of the input element.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line182">line 182</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Logarithm matrix.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(fn)</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Creates a new matrix where each element is the result of executiong
the provided function with signature (element, i, j).
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fn</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Function for calculating each element.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line164">line 164</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resulting mapped matrix.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id="mulOp"><span class="type-signature"></span>mulOp<span class="signature">(matrix, op)</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Given a matrix an an operation function, applies this operation
multiplying this matrix with the provided one.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matrix</code></td>
<td class="type">
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</td>
<td class="description last">Matrix to operate with this.</td>
</tr>
<tr>
<td class="name"><code>op</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Multiply operation.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line269">line 269</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Result matrix of multiplying both matrix.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id="multiply"><span class="type-signature"></span>multiply<span class="signature">(matrix, activation)</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Multiply two matrix.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matrix</code></td>
<td class="type">
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</td>
<td class="description last">Input matrix.</td>
</tr>
<tr>
<td class="name"><code>activation</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Optional activation fucntion.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line301">line 301</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Multiplication of the matrix.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
<h4 class="name" id="row"><span class="type-signature"></span>row<span class="signature">(i)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Return a row of the matrix as a vector.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>i</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Row number.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line74">line 74</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Row of the matrix as a vector.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="rowCount"><span class="type-signature"></span>rowCount<span class="signature">()</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Return the amount of rows of the matrix.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line101">line 101</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Amount of rows of the matrix.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="setElements"><span class="type-signature"></span>setElements<span class="signature">(els)</span><span class="type-signature"></span></h4>
<div class="description">
Clone the input elemnts and assign to this instance elements.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>els</code></td>
<td class="type">
<span class="param-type">Array.<Array.<Number>></span>
|
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</td>
<td class="description last">Input elements.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line48">line 48</a>
</li></ul></dd>
</dl>
<h4 class="name" id="subtract"><span class="type-signature"></span>subtract<span class="signature">(matrix)</span><span class="type-signature"></span></h4>
<div class="description">
Performs a substraction element by element between two matrix.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matrix</code></td>
<td class="type">
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</td>
<td class="description last">Input matrix.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line248">line 248</a>
</li></ul></dd>
</dl>
<h4 class="name" id="transpose"><span class="type-signature"></span>transpose<span class="signature">()</span><span class="type-signature"> → {<a href="Matrix.html">Matrix</a>}</span></h4>
<div class="description">
Creates a new Matrix that is the transposed of this one
(rows become columns).
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_matrix.js.html">math/matrix.js</a>, <a href="math_matrix.js.html#line145">line 145</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Matrix that is transposed of this one.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Matrix.html">Matrix</a></span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BinaryNeuralNetworkClassifier.html">BinaryNeuralNetworkClassifier</a></li><li><a href="Classifier.html">Classifier</a></li><li><a href="ConversationContext.html">ConversationContext</a></li><li><a href="DutchStemmer.html">DutchStemmer</a></li><li><a href="EnglishStemmer.html">EnglishStemmer</a></li><li><a href="EnumNamedEntity.html">EnumNamedEntity</a></li><li><a href="Evaluator.html">Evaluator</a></li><li><a href="HungarianStemmer.html">HungarianStemmer</a></li><li><a href="ItalianStemmer.html">ItalianStemmer</a></li><li><a href="Language.html">Language</a></li><li><a href="LogisticRegressionClassifier.html">LogisticRegressionClassifier</a></li><li><a href="Matrix.html">Matrix</a></li><li><a href="MemoryConversationContext.html">MemoryConversationContext</a></li><li><a href="NamedEntity.html">NamedEntity</a></li><li><a href="NerManager.html">NerManager</a></li><li><a href="NlgManager.html">NlgManager</a></li><li><a href="NlpClassifier.html">NlpClassifier</a></li><li><a href="NlpManager.html">NlpManager</a></li><li><a href="NorwegianStemmer.html">NorwegianStemmer</a></li><li><a href="PortugueseStemmer.html">PortugueseStemmer</a></li><li><a href="Recognizer.html">Recognizer</a></li><li><a href="RegexNamedEntity.html">RegexNamedEntity</a></li><li><a href="RomanianStemmer.html">RomanianStemmer</a></li><li><a href="RussianStemmer.html">RussianStemmer</a></li><li><a href="SentimentAnalyzer.html">SentimentAnalyzer</a></li><li><a href="SentimentManager.html">SentimentManager</a></li><li><a href="SimilarSearch.html">SimilarSearch</a></li><li><a href="SlotManager.html">SlotManager</a></li><li><a href="StemmerJa.html">StemmerJa</a></li><li><a href="SwedishStemmer.html">SwedishStemmer</a></li><li><a href="Tokenizer.html">Tokenizer</a></li><li><a href="TrimNamedEntity.html">TrimNamedEntity</a></li><li><a href="TurkishStemmer.html">TurkishStemmer</a></li><li><a href="Vector.html">Vector</a></li><li><a href="XTable.html">XTable</a></li></ul><h3>Global</h3><ul><li><a href="global.html#endsinArr">endsinArr</a></li><li><a href="global.html#prelude">prelude</a></li><li><a href="global.html#regions">regions</a></li><li><a href="global.html#stem">stem</a></li><li><a href="global.html#stopwords">stopwords</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 13 2018 19:14:51 GMT+0200 (CEST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>