apatite/docs/Apatite/LinearAlgebra/Matrix.html

2848 lines
109 KiB
HTML
Raw Normal View History

2019-06-13 02:23:54 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.29.0">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../js/doc.js"></script>
<script type="text/javascript">
CrystalDoc.base_path = "../../";
</script>
<meta id="repository-name" content="github.com/watzon/apatite">
2019-07-10 01:18:01 +00:00
<title>Apatite::LinearAlgebra::Matrix(T) - github.com/watzon/apatite</title>
2019-06-13 02:23:54 +00:00
</head>
<body>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="repository-links">
<a href="../../index.html">README</a>
</div>
</div>
<div class="search-results" class="hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="github.com/watzon/apatite/Apatite" data-name="apatite">
<a href="../../Apatite.html">Apatite</a>
<ul>
<li class="parent open current" data-id="github.com/watzon/apatite/Apatite/LinearAlgebra" data-name="apatite::linearalgebra">
<a href="../../Apatite/LinearAlgebra.html">LinearAlgebra</a>
<ul>
2019-07-10 01:18:01 +00:00
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/ErrDimensionMismatch" data-name="apatite::linearalgebra::errdimensionmismatch">
<a href="../../Apatite/LinearAlgebra/ErrDimensionMismatch.html">ErrDimensionMismatch</a>
</li>
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/ErrNotRegular" data-name="apatite::linearalgebra::errnotregular">
<a href="../../Apatite/LinearAlgebra/ErrNotRegular.html">ErrNotRegular</a>
</li>
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/ErrOperationNotDefined" data-name="apatite::linearalgebra::erroperationnotdefined">
<a href="../../Apatite/LinearAlgebra/ErrOperationNotDefined.html">ErrOperationNotDefined</a>
</li>
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/Error" data-name="apatite::linearalgebra::error">
<a href="../../Apatite/LinearAlgebra/Error.html">Error</a>
</li>
2019-07-10 02:08:46 +00:00
<li class="parent open current" data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix" data-name="apatite::linearalgebra::matrix(t)">
2019-06-13 02:23:54 +00:00
<a href="../../Apatite/LinearAlgebra/Matrix.html">Matrix</a>
2019-07-10 02:08:46 +00:00
<ul>
2019-06-13 02:23:54 +00:00
2019-07-10 02:08:46 +00:00
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix/EigenvalueDecomposition" data-name="apatite::linearalgebra::matrix::eigenvaluedecomposition">
<a href="../../Apatite/LinearAlgebra/Matrix/EigenvalueDecomposition.html">EigenvalueDecomposition</a>
2019-06-13 02:23:54 +00:00
</li>
2019-07-10 02:08:46 +00:00
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix/LupDecomposition" data-name="apatite::linearalgebra::matrix::lupdecomposition">
<a href="../../Apatite/LinearAlgebra/Matrix/LupDecomposition.html">LupDecomposition</a>
2019-07-10 01:18:01 +00:00
</li>
</ul>
</li>
2019-07-10 02:08:46 +00:00
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray" data-name="apatite::linearalgebra::ndarray">
<a href="../../Apatite/LinearAlgebra/NDArray.html">NDArray</a>
2019-07-10 01:18:01 +00:00
2019-07-10 02:08:46 +00:00
</li>
2019-07-10 01:18:01 +00:00
2019-07-10 02:08:46 +00:00
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/Vector" data-name="apatite::linearalgebra::vector(t)">
<a href="../../Apatite/LinearAlgebra/Vector.html">Vector</a>
2019-07-10 01:18:01 +00:00
</li>
2019-07-10 02:08:46 +00:00
<li class=" " data-id="github.com/watzon/apatite/Apatite/LinearAlgebra/ZeroVectorError" data-name="apatite::linearalgebra::zerovectorerror">
<a href="../../Apatite/LinearAlgebra/ZeroVectorError.html">ZeroVectorError</a>
2019-07-10 01:18:01 +00:00
</li>
2019-06-13 02:23:54 +00:00
</ul>
</li>
</ul>
</li>
<li class=" " data-id="github.com/watzon/apatite/Array" data-name="array(t)">
<a href="../../Array.html">Array</a>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
2019-07-10 01:18:01 +00:00
<span class="kind">class</span> Apatite::LinearAlgebra::Matrix(T)
2019-06-13 02:23:54 +00:00
</h1>
2019-07-10 01:18:01 +00:00
<ul class="superclass-hierarchy"><li class="superclass"><a href="../../Apatite/LinearAlgebra/Matrix.html">Apatite::LinearAlgebra::Matrix(T)</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
2019-06-13 02:23:54 +00:00
<h2>Included Modules</h2>
<ul class="other-types-list">
2019-07-10 01:18:01 +00:00
<li class="other-type">Comparable(<a href="../../Apatite/LinearAlgebra/Matrix.html">Apatite::LinearAlgebra::Matrix(T)</a>)</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="other-type">Enumerable(<a href="../../Apatite/LinearAlgebra/Vector.html">Apatite::LinearAlgebra::Vector(T)</a>)</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="other-type">Indexable(<a href="../../Apatite/LinearAlgebra/Vector.html">Apatite::LinearAlgebra::Vector(T)</a>)</li>
2019-06-13 02:23:54 +00:00
</ul>
<h2>Defined in:</h2>
2019-07-10 02:22:15 +00:00
<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix/eigenvalue_decomposition.cr#L2" target="_blank">
2019-07-10 02:08:46 +00:00
apatite/linear_algebra/matrix/eigenvalue_decomposition.cr
</a>
<br/>
2019-07-10 02:22:15 +00:00
<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix/lup_decomposition.cr#L2" target="_blank">
2019-07-10 02:08:46 +00:00
apatite/linear_algebra/matrix/lup_decomposition.cr
</a>
<br/>
2019-07-10 02:22:15 +00:00
<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L6" target="_blank">
2019-06-13 02:23:54 +00:00
apatite/linear_algebra/matrix.cr
</a>
<br/>
2019-07-10 01:18:01 +00:00
<h2>Constant Summary</h2>
<dl>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<dt class="entry-const" id="SELECTORS">
<strong>SELECTORS</strong> = <code>{all: <span class="n">true</span>, diagonal: <span class="n">true</span>, off_diagonal: <span class="n">true</span>, lower: <span class="n">true</span>, strict_lower: <span class="n">true</span>, strict_upper: <span class="n">true</span>, upper: <span class="n">true</span>}</code>
</dt>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
</dl>
2019-06-13 02:23:54 +00:00
<h2>Class Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#%5B%5D%28%2Arows%29-class-method" class="signature"><strong>.[]</strong>(*rows)</a>
<div class="summary"><p>Creates a matrix where each argument is a row.</p></div>
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#build%28row_count%2Ccolumn_count%3Drow_count%2C%26block%3AInt32%2CInt32-%3ET%29-class-method" class="signature"><strong>.build</strong>(row_count, column_count = row_count, &block : Int32, Int32 -> T)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates a matrix of size +row_count+ x +column_count+.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#column_vector%28column%29-class-method" class="signature"><strong>.column_vector</strong>(column)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Creates a single-column matrix where the values of that column are as given in <code><a href="../../Apatite/LinearAlgebra/Matrix.html#column%28j%29-instance-method">#column</a></code>.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#columns%28columns%29-class-method" class="signature"><strong>.columns</strong>(columns)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates a matrix using +columns+ as an array of column vectors.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#combine%28%2Amatrices%2C%26block%29-class-method" class="signature"><strong>.combine</strong>(*matrices, &block)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Create a matrix by combining matrices entrywise, using the given block</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#diagonal%28values%3AIndexable%28T%29%2Cdummy%3Dnil%29-class-method" class="signature"><strong>.diagonal</strong>(values : Indexable(T), dummy = <span class="n">nil</span>)</a>
2019-06-13 02:23:54 +00:00
<div class="summary"><p>Creates a matrix where the diagonal elements are composed of <code>values</code>.</p></div>
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#diagonal%28%2Avalues%3AT%29-class-method" class="signature"><strong>.diagonal</strong>(*values : T)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Creates a matrix where the diagonal elements are composed of <code>values</code>.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#empty%28row_count%3D0%2Ccolumn_count%3D0%29-class-method" class="signature"><strong>.empty</strong>(row_count = <span class="n">0</span>, column_count = <span class="n">0</span>)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates a empty matrix of <code><a href="../../Apatite/LinearAlgebra/Matrix.html#row_count-instance-method">#row_count</a></code> x <code><a href="../../Apatite/LinearAlgebra/Matrix.html#column_count%3AInt32-instance-method">#column_count</a></code>.</p></div>
</li>
2019-06-13 02:23:54 +00:00
<li class="entry-summary">
<a href="#hstack%28x%2C%2Amatrices%29-class-method" class="signature"><strong>.hstack</strong>(x, *matrices)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Create a matrix by stacking matrices horizontally</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#identity%28n%29-class-method" class="signature"><strong>.identity</strong>(n)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates an <code>n</code> by <code>n</code> identity matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#row_vector%28row%29-class-method" class="signature"><strong>.row_vector</strong>(row)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates a single-row matrix where the values of that row are as given in <code><a href="../../Apatite/LinearAlgebra/Matrix.html#row%28i%2C%26block%3AVector-%3E%29-instance-method">#row</a></code>.</p></div>
</li>
<li class="entry-summary">
<a href="#rows%28rows%3AIndexable%28Array%28T%29%29%2Ccopy%3Dtrue%29-class-method" class="signature"><strong>.rows</strong>(rows : Indexable(Array(T)), copy = <span class="n">true</span>)</a>
<div class="summary"><p>Creates a matrix where +rows+ is an array of arrays, each of which is a row of the matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#scalar%28n%2Cvalue%3AT%29-class-method" class="signature"><strong>.scalar</strong>(n, value : T)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates an +n+ by +n+ diagonal matrix where each diagonal element is <code>value</code>.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#unit%28n%3AT%29-class-method" class="signature"><strong>.unit</strong>(n : T)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Creates an <code>n</code> by <code>n</code> identity matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#vstack%28x%2C%2Amatrices%29-class-method" class="signature"><strong>.vstack</strong>(x, *matrices)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Create a matrix by stacking matrices vertically</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#zero%28row_count%2Ccolumn_count%3Drow_count%29-class-method" class="signature"><strong>.zero</strong>(row_count, column_count = row_count)</a>
<div class="summary"><p>Creates a zero matrix.</p></div>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class="list-summary">
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#%2A%28other%29-instance-method" class="signature"><strong>#*</strong>(other)</a>
<div class="summary"><p>Matrix multiplication</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#%2A%2A%28other%29-instance-method" class="signature"><strong>#**</strong>(other)</a>
<div class="summary"><p>Matrix exponentiation.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#%2B%28other%3AMatrix%7CIndexable%29-instance-method" class="signature"><strong>#+</strong>(other : Matrix | Indexable)</a>
<div class="summary"><p>Matrix addition</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#-%28other%3AMatrix%7CIndexable%29-instance-method" class="signature"><strong>#-</strong>(other : Matrix | Indexable)</a>
<div class="summary"><p>Matrix subtraction</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#%2F%28other%29-instance-method" class="signature"><strong>#/</strong>(other)</a>
<div class="summary"><p>Matrix division (multiplication by the inverse).</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#%3D%3D%28other%3AMatrix%29-instance-method" class="signature"><strong>#==</strong>(other : Matrix)</a>
<div class="summary"><p>Equality operator</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#%5B%5D%28i%29-instance-method" class="signature"><strong>#[]</strong>(i)</a>
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns row <code>i</code> of the matrix as an Array.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#%5B%5D%28i%2Cj%29-instance-method" class="signature"><strong>#[]</strong>(i, j)</a>
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns element (<code>i</code>, <code>j</code>) of the matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#%5B%5D%3D%28i%2Cj%2Cv%3AT%29-instance-method" class="signature"><strong>#[]=</strong>(i, j, v : T)</a>
<div class="summary"><p>Set the value at index (<code>i</code>, <code>j</code>).</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#%5B%5D%3F%28i%29-instance-method" class="signature"><strong>#[]?</strong>(i)</a>
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns row <code>i</code> of the matrix as an Array.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#%5B%5D%3F%28i%2Cj%29-instance-method" class="signature"><strong>#[]?</strong>(i, j)</a>
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns element (<code>i</code>, <code>j</code>) of the matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#adjugate-instance-method" class="signature"><strong>#adjugate</strong></a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns the adjugate of the matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#clone-instance-method" class="signature"><strong>#clone</strong></a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns a clone of the matrix, so that the contents of each do not reference identical objects.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#coerce%28klass%29-instance-method" class="signature"><strong>#coerce</strong>(klass)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Attempt to coerce the elements in the matrix to another type.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#cofactor%28row%2Ccolumn%29-instance-method" class="signature"><strong>#cofactor</strong>(row, column)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column).</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#column%28j%29-instance-method" class="signature"><strong>#column</strong>(j)</a>
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns column vector <code>j</code> of the Matrix as a Vector (starting at 0).</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#column%28j%2C%26block%3AT-%3E%29-instance-method" class="signature"><strong>#column</strong>(j, &block : T -> )</a>
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns a block which yields every item in column <code>j</code> of the Matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#column%3F%28j%29-instance-method" class="signature"><strong>#column?</strong>(j)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns column vector <code>j</code> of the Matrix as a Vector (starting at 0).</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#column_count%3AInt32-instance-method" class="signature"><strong>#column_count</strong> : Int32</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns the number of columns.</p></div>
</li>
2019-07-10 02:22:15 +00:00
<li class="entry-summary">
<a href="#column_vectors-instance-method" class="signature"><strong>#column_vectors</strong></a>
<div class="summary"><p>Returns an array of the column vectors of the matrix.</p></div>
</li>
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#combine%28%2Amatrices%2C%26block%29-instance-method" class="signature"><strong>#combine</strong>(*matrices, &block)</a>
<div class="summary"><p>Create a matrix by combining matrices entrywise, using the given block</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#conj-instance-method" class="signature"><strong>#conj</strong></a>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns the conjugate of the matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#determinant-instance-method" class="signature"><strong>#determinant</strong></a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns the determinant of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#diagonal%3F-instance-method" class="signature"><strong>#diagonal?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a diagonal matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#each%28which%3D%3Aall%2C%26block%3AT-%3E%29-instance-method" class="signature"><strong>#each</strong>(which = <span class="n">:all</span>, &block : T -> )</a>
<div class="summary"><p>Yields all elements of the matrix, starting with those of the first row, or returns an Enumerator if no block given.</p></div>
</li>
<li class="entry-summary">
<a href="#each_with_index%28which%3D%3Aall%2C%26block%3AT%2CInt32%2CInt32-%3E%29-instance-method" class="signature"><strong>#each_with_index</strong>(which = <span class="n">:all</span>, &block : T, Int32, Int32 -> )</a>
<div class="summary"><p>Same as #each, but the row index and column index in addition to the element</p></div>
</li>
<li class="entry-summary">
<a href="#eigensystem-instance-method" class="signature"><strong>#eigensystem</strong></a>
2019-07-10 02:08:46 +00:00
<div class="summary"><p>Returns the Eigensystem of the matrix See <code><a href="../../Apatite/LinearAlgebra/Matrix/EigenvalueDecomposition.html">EigenvalueDecomposition</a></code>.</p></div>
2019-07-10 01:18:01 +00:00
</li>
<li class="entry-summary">
<a href="#empty%3F-instance-method" class="signature"><strong>#empty?</strong></a>
<div class="summary"><p>Returns true if this matrix is empty.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#first_minor%28row%2Ccolumn%29-instance-method" class="signature"><strong>#first_minor</strong>(row, column)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns the submatrix obtained by deleting the specified row and column.</p></div>
</li>
<li class="entry-summary">
<a href="#hadamard_product%28m%29-instance-method" class="signature"><strong>#hadamard_product</strong>(m)</a>
<div class="summary"><p>Hadamard product</p></div>
</li>
<li class="entry-summary">
<a href="#hermitian%3F-instance-method" class="signature"><strong>#hermitian?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is an hermitian matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#hstack%28%2Amatrices%29-instance-method" class="signature"><strong>#hstack</strong>(*matrices)</a>
<div class="summary"><p>Returns a new matrix resulting by stacking horizontally the receiver with the given matrices</p></div>
</li>
<li class="entry-summary">
<a href="#imag-instance-method" class="signature"><strong>#imag</strong></a>
<div class="summary"><p>Returns the imaginary part of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#index%28i%2Cselector%3D%3Aall%29-instance-method" class="signature"><strong>#index</strong>(i, selector = <span class="n">:all</span>)</a>
<div class="summary"><p>The index method is specialized to return the index as {row, column} It also accepts an optional <code>selector</code> argument, see <code><a href="../../Apatite/LinearAlgebra/Matrix.html#each%28which%3D%3Aall%2C%26block%3AT-%3E%29-instance-method">#each</a></code> for details.</p></div>
</li>
<li class="entry-summary">
<a href="#index%28selector%3D%3Aall%2C%26block%3AT-%3EBool%29-instance-method" class="signature"><strong>#index</strong>(selector = <span class="n">:all</span>, &block : T -> Bool)</a>
<div class="summary"><p>Returns the index as {row, column}, using <code>&block</code> to filter the result.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
<a href="#inverse-instance-method" class="signature"><strong>#inverse</strong></a>
<div class="summary"><p>Returns the inverse of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#laplace_expansion%28%2A%2Crow%3Dnil%2Ccolumn%3Dnil%29-instance-method" class="signature"><strong>#laplace_expansion</strong>(*, row = <span class="n">nil</span>, column = <span class="n">nil</span>)</a>
<div class="summary"><p>Returns the Laplace expansion along given row or column.</p></div>
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#lower_triangular%3F-instance-method" class="signature"><strong>#lower_triangular?</strong></a>
<div class="summary"><p>Returns true if this matrix is a lower triangular matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#lup-instance-method" class="signature"><strong>#lup</strong></a>
<div class="summary"><p>Returns the LUP decomposition of the matrix See +LUPDecomposition+.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#map%28%26block%3AT-%3ET%29-instance-method" class="signature"><strong>#map</strong>(&block : T -> T)</a>
<div class="summary"><p>Returns a Matrix that is the result of iteration of the given block over all elements in the matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#minor%28from_row%3AInt%2Cnrows%3AInt%2Cfrom_col%3AInt%2Cncols%3AInt%29-instance-method" class="signature"><strong>#minor</strong>(from_row : Int, nrows : Int, from_col : Int, ncols : Int)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns a section of the Matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 02:22:15 +00:00
<a href="#minor%28row_range%3ARange%2Ccol_range%3ARange%29-instance-method" class="signature"><strong>#minor</strong>(row_range : Range, col_range : Range)</a>
2019-07-10 01:18:01 +00:00
<div class="summary"><p>Returns a section of the Matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#normal%3F-instance-method" class="signature"><strong>#normal?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a normal matrix.</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#orthogonal%3F-instance-method" class="signature"><strong>#orthogonal?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is an orthogonal matrix</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#permutation%3F-instance-method" class="signature"><strong>#permutation?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a permutation matrix</p></div>
2019-06-13 02:23:54 +00:00
</li>
<li class="entry-summary">
2019-07-10 01:18:01 +00:00
<a href="#pretty_print%28pp%29%3ANil-instance-method" class="signature"><strong>#pretty_print</strong>(pp) : Nil</a>
2019-06-13 02:23:54 +00:00
</li>
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#rank-instance-method" class="signature"><strong>#rank</strong></a>
<div class="summary"><p>Returns the rank of the matrix.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#real-instance-method" class="signature"><strong>#real</strong></a>
<div class="summary"><p>Returns the real part of the matrix.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#real%3F-instance-method" class="signature"><strong>#real?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this matrix contains real numbers, i.e.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#rect-instance-method" class="signature"><strong>#rect</strong></a>
<div class="summary"><p>Returns an array containing matrices corresponding to the real and imaginary parts of the matrix</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#regular%3F-instance-method" class="signature"><strong>#regular?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a regular (i.e.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#round%28n%3D0%29-instance-method" class="signature"><strong>#round</strong>(n = <span class="n">0</span>)</a>
<div class="summary"><p>Returns a matrix with entries rounded to the given precision (see <code>Float#round</code>)</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#row%28i%2C%26block%3AVector-%3E%29-instance-method" class="signature"><strong>#row</strong>(i, &block : Vector -> )</a>
<div class="summary"><p>Returns a block which yields every Vector in the row (starting at 0).</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#row%28i%29-instance-method" class="signature"><strong>#row</strong>(i)</a>
<div class="summary"><p>Returns row vector number <code>i</code> of the Matrix as a Vector (starting at 0 like a good boy).</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#row%3F%28i%29-instance-method" class="signature"><strong>#row?</strong>(i)</a>
<div class="summary"><p>Returns row vector number <code>i</code> of the Matrix as a Vector (starting at 0 like a good boy).</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#row_count-instance-method" class="signature"><strong>#row_count</strong></a>
<div class="summary"><p>Returns the number of rows.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<li class="entry-summary">
<a href="#row_vectors-instance-method" class="signature"><strong>#row_vectors</strong></a>
<div class="summary"><p>Returns an array of the row vectors of the matrix.</p></div>
</li>
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#singular%3F-instance-method" class="signature"><strong>#singular?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a singular matrix.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#square%3F-instance-method" class="signature"><strong>#square?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a square matrix.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#swap_columns%28col1%2Ccol2%29-instance-method" class="signature"><strong>#swap_columns</strong>(col1, col2)</a>
<div class="summary"><p>Swaps <code>col1</code> and <code>col2</code></p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#swap_rows%28row1%2Crow2%29-instance-method" class="signature"><strong>#swap_rows</strong>(row1, row2)</a>
<div class="summary"><p>Swaps <code>row1</code> and <code>row2</code></p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#symmetric%3F-instance-method" class="signature"><strong>#symmetric?</strong></a>
<div class="summary"><p>Returns +true+ if this is a symmetric matrix.</p></div>
</li>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<li class="entry-summary">
<a href="#t-instance-method" class="signature"><strong>#t</strong></a>
<div class="summary"><p>Returns the transpose of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#to_a-instance-method" class="signature"><strong>#to_a</strong></a>
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Returns an array of arrays that describe the rows of the matrix.</p></div>
2019-07-10 01:18:01 +00:00
</li>
<li class="entry-summary">
<a href="#to_json%28json%3AJSON%3A%3ABuilder%29-instance-method" class="signature"><strong>#to_json</strong>(json : JSON::Builder)</a>
2019-07-10 02:22:15 +00:00
<div class="summary"><p>Convert the matrix to a json array</p></div>
2019-07-10 01:18:01 +00:00
</li>
<li class="entry-summary">
<a href="#to_s%28io%29-instance-method" class="signature"><strong>#to_s</strong>(io)</a>
</li>
<li class="entry-summary">
<a href="#tr-instance-method" class="signature"><strong>#tr</strong></a>
<div class="summary"><p>Returns the trace (sum of diagonal elements) of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#trace-instance-method" class="signature"><strong>#trace</strong></a>
<div class="summary"><p>Returns the trace (sum of diagonal elements) of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#transpose-instance-method" class="signature"><strong>#transpose</strong></a>
<div class="summary"><p>Returns the transpose of the matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#unitary%3F-instance-method" class="signature"><strong>#unitary?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a unitary matrix</p></div>
</li>
<li class="entry-summary">
<a href="#unsafe_fetch%28i%29-instance-method" class="signature"><strong>#unsafe_fetch</strong>(i)</a>
</li>
<li class="entry-summary">
<a href="#upper_triangular%3F-instance-method" class="signature"><strong>#upper_triangular?</strong></a>
<div class="summary"><p>Returns true if this matrix is a upper triangular matrix.</p></div>
</li>
<li class="entry-summary">
<a href="#vstack%28%2Amatrices%29-instance-method" class="signature"><strong>#vstack</strong>(*matrices)</a>
<div class="summary"><p>Returns a new matrix resulting by stacking vertically the receiver with the given matrices</p></div>
</li>
<li class="entry-summary">
<a href="#zero%3F-instance-method" class="signature"><strong>#zero?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this is a matrix with only zero elements</p></div>
</li>
</ul>
<div class="methods-inherited">
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
</div>
<h2>Class Method Detail</h2>
<div class="entry-detail" id="[](*rows)-class-method">
<div class="signature">
def self.<strong>[]</strong>(*rows)
<a class="method-permalink" href="#%5B%5D%28%2Arows%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a matrix where each argument is a row.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">25</span>, <span class="n">93</span>], [<span class="n">-1</span>, <span class="n">66</span>]]
<span class="c"># =&gt; [ 25, 93,</span>
<span class="c"># -1, 66 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L20" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="build(row_count,column_count=row_count,&amp;block:Int32,Int32-&gt;T)-class-method">
<div class="signature">
def self.<strong>build</strong>(row_count, column_count = row_count, &block : Int32, Int32 -> T)
<a class="method-permalink" href="#build%28row_count%2Ccolumn_count%3Drow_count%2C%26block%3AInt32%2CInt32-%3ET%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a matrix of size +row_count+ x +column_count+.
It fills the values by calling the given block,
passing the current row and column.
Returns an enumerator if no block is given.</p>
<pre><code>m <span class="o">=</span> <span class="t">Matrix</span>.build(<span class="n">2</span>, <span class="n">4</span>) { <span class="o">|</span>row, col<span class="o">|</span> col <span class="o">-</span> row }
<span class="c"># =&gt; Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]]</span>
m <span class="o">=</span> <span class="t">Matrix</span>.build(<span class="n">3</span>) { rand }
<span class="c"># =&gt; a 3x3 matrix with random elements</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L69" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="column_vector(column)-class-method">
<div class="signature">
def self.<strong>column_vector</strong>(column)
<a class="method-permalink" href="#column_vector%28column%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a single-column matrix where the values of that column are as given
2019-07-10 02:22:15 +00:00
in <code><a href="../../Apatite/LinearAlgebra/Matrix.html#column%28j%29-instance-method">#column</a></code>.</p>
2019-07-10 01:18:01 +00:00
<pre><code><span class="t">Matrix</span>.column_vector([<span class="n">4</span>,<span class="n">5</span>,<span class="n">6</span>])
<span class="c"># =&gt; [ 4,</span>
<span class="c"># 5,</span>
<span class="c"># 6 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L166" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="columns(columns)-class-method">
<div class="signature">
def self.<strong>columns</strong>(columns)
<a class="method-permalink" href="#columns%28columns%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a matrix using +columns+ as an array of column vectors.</p>
<pre><code><span class="t">Matrix</span>.columns([[<span class="n">25</span>, <span class="n">93</span>], [<span class="n">-1</span>, <span class="n">66</span>]])
<span class="c"># =&gt; [ 25, -1,</span>
<span class="c"># 93, 66 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L54" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="combine(*matrices,&amp;block)-class-method">
<div class="signature">
def self.<strong>combine</strong>(*matrices, &block)
<a class="method-permalink" href="#combine%28%2Amatrices%2C%26block%29-class-method">#</a>
</div>
<div class="doc"><p>Create a matrix by combining matrices entrywise, using the given block</p>
<pre><code>x <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">6</span>, <span class="n">6</span>], [<span class="n">4</span>, <span class="n">4</span>]]
y <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
<span class="t">Matrix</span>.combine(x, y) {<span class="o">|</span>a, b<span class="o">|</span> a <span class="o">-</span> b}
<span class="c"># =&gt; Matrix[[5, 4], [1, 0]]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L245" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="diagonal(values:Indexable(T),dummy=nil)-class-method">
<div class="signature">
def self.<strong>diagonal</strong>(values : Indexable(T), dummy = <span class="n">nil</span>)
<a class="method-permalink" href="#diagonal%28values%3AIndexable%28T%29%2Cdummy%3Dnil%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a matrix where the diagonal elements are composed of <code>values</code>.</p>
<pre><code><span class="t">Matrix</span>.diagonal(<span class="n">9</span>, <span class="n">5</span>, <span class="n">-3</span>)
<span class="c"># =&gt; [ 9, 0, 0,</span>
<span class="c"># 0, 5, 0,</span>
<span class="c"># 0, 0, -3 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L89" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="diagonal(*values:T)-class-method">
<div class="signature">
def self.<strong>diagonal</strong>(*values : T)
<a class="method-permalink" href="#diagonal%28%2Avalues%3AT%29-class-method">#</a>
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Creates a matrix where the diagonal elements are composed of <code>values</code>.</p>
<pre><code><span class="t">Matrix</span>.diagonal(<span class="n">9</span>, <span class="n">5</span>, <span class="n">-3</span>)
<span class="c"># =&gt; [ 9, 0, 0,</span>
<span class="c"># 0, 5, 0,</span>
<span class="c"># 0, 0, -3 ]</span></code></pre></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L101" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="empty(row_count=0,column_count=0)-class-method">
<div class="signature">
def self.<strong>empty</strong>(row_count = <span class="n">0</span>, column_count = <span class="n">0</span>)
<a class="method-permalink" href="#empty%28row_count%3D0%2Ccolumn_count%3D0%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a empty matrix of <code><a href="../../Apatite/LinearAlgebra/Matrix.html#row_count-instance-method">#row_count</a></code> x <code><a href="../../Apatite/LinearAlgebra/Matrix.html#column_count%3AInt32-instance-method">#column_count</a></code>.
At least one of <code><a href="../../Apatite/LinearAlgebra/Matrix.html#row_count-instance-method">#row_count</a></code> or <code><a href="../../Apatite/LinearAlgebra/Matrix.html#column_count%3AInt32-instance-method">#column_count</a></code> must be 0.</p>
<pre><code>m <span class="o">=</span> <span class="t">Matrix</span>(<span class="t">Int32</span>).empty(<span class="n">2</span>, <span class="n">0</span>)
m <span class="o">==</span> <span class="t">Matrix</span>[ <span class="o">[]</span>, <span class="o">[]</span> ]
<span class="c"># =&gt; true</span>
n <span class="o">=</span> <span class="t">Matrix</span>(<span class="t">Int32</span>).empty(<span class="n">0</span>, <span class="n">3</span>)
m <span class="o">*</span> n
<span class="c"># =&gt; Matrix[[0, 0, 0], [0, 0, 0]]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L182" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="hstack(x,*matrices)-class-method">
<div class="signature">
def self.<strong>hstack</strong>(x, *matrices)
<a class="method-permalink" href="#hstack%28x%2C%2Amatrices%29-class-method">#</a>
</div>
<div class="doc"><p>Create a matrix by stacking matrices horizontally</p>
<pre><code>x <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
y <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">5</span>, <span class="n">6</span>], [<span class="n">7</span>, <span class="n">8</span>]]
<span class="t">Matrix</span>.hstack(x, y)
<span class="c"># =&gt; Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L217" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="identity(n)-class-method">
<div class="signature">
def self.<strong>identity</strong>(n)
<a class="method-permalink" href="#identity%28n%29-class-method">#</a>
</div>
<div class="doc"><p>Creates an <code>n</code> by <code>n</code> identity matrix.</p>
<pre><code><span class="t">Matrix</span>.identity(<span class="n">2</span>)
<span class="c"># =&gt; [ 1, 0,</span>
<span class="c"># 0, 1 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L124" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="row_vector(row)-class-method">
<div class="signature">
def self.<strong>row_vector</strong>(row)
<a class="method-permalink" href="#row_vector%28row%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a single-row matrix where the values of that row are as given in
<code><a href="../../Apatite/LinearAlgebra/Matrix.html#row%28i%2C%26block%3AVector-%3E%29-instance-method">#row</a></code>.</p>
<pre><code><span class="t">Matrix</span>.row_vector([<span class="n">4</span>,<span class="n">5</span>,<span class="n">6</span>])
<span class="c"># =&gt; [ 4, 5, 6 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L152" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="rows(rows:Indexable(Array(T)),copy=true)-class-method">
<div class="signature">
def self.<strong>rows</strong>(rows : Indexable(<a href="../../Array.html">Array</a>(T)), copy = <span class="n">true</span>)
<a class="method-permalink" href="#rows%28rows%3AIndexable%28Array%28T%29%29%2Ccopy%3Dtrue%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a matrix where +rows+ is an array of arrays, each of which is a row
of the matrix. If the optional argument +copy+ is false, use the given
arrays as the internal structure of the matrix without copying.</p>
<pre><code><span class="t">Matrix</span>.rows([[<span class="n">25</span>, <span class="n">93</span>], [<span class="n">-1</span>, <span class="n">66</span>]])
<span class="c"># =&gt; [ 25, 93,</span>
<span class="c"># -1, 66 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L33" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="scalar(n,value:T)-class-method">
<div class="signature">
def self.<strong>scalar</strong>(n, value : T)
<a class="method-permalink" href="#scalar%28n%2Cvalue%3AT%29-class-method">#</a>
</div>
<div class="doc"><p>Creates an +n+ by +n+ diagonal matrix where each diagonal element is
<code>value</code>.</p>
<pre><code><span class="t">Matrix</span>.scalar(<span class="n">2</span>, <span class="n">5</span>)
<span class="c"># =&gt; [ 5, 0,</span>
<span class="c"># 0, 5 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L113" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="unit(n:T)-class-method">
<div class="signature">
def self.<strong>unit</strong>(n : T)
<a class="method-permalink" href="#unit%28n%3AT%29-class-method">#</a>
</div>
<div class="doc"><p>Creates an <code>n</code> by <code>n</code> identity matrix.</p>
<pre><code><span class="t">Matrix</span>.identity(<span class="n">2</span>)
<span class="c"># =&gt; [ 1, 0,</span>
<span class="c"># 0, 1 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L129" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="vstack(x,*matrices)-class-method">
<div class="signature">
def self.<strong>vstack</strong>(x, *matrices)
<a class="method-permalink" href="#vstack%28x%2C%2Amatrices%29-class-method">#</a>
</div>
<div class="doc"><p>Create a matrix by stacking matrices vertically</p>
<pre><code>x <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
y <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">5</span>, <span class="n">6</span>], [<span class="n">7</span>, <span class="n">8</span>]]
<span class="t">Matrix</span>.vstack(x, y)
<span class="c"># =&gt; Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L197" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="zero(row_count,column_count=row_count)-class-method">
<div class="signature">
def self.<strong>zero</strong>(row_count, column_count = row_count)
<a class="method-permalink" href="#zero%28row_count%2Ccolumn_count%3Drow_count%29-class-method">#</a>
</div>
<div class="doc"><p>Creates a zero matrix.</p>
<pre><code><span class="t">Matrix</span>.zero(<span class="n">2</span>)
<span class="c"># =&gt; [ 0, 0,</span>
<span class="c"># 0, 0 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L140" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<h2>Instance Method Detail</h2>
<div class="entry-detail" id="*(other)-instance-method">
<div class="signature">
def <strong>*</strong>(other)
<a class="method-permalink" href="#%2A%28other%29-instance-method">#</a>
</div>
<div class="doc"><p>Matrix multiplication</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">2</span>,<span class="n">4</span>], [<span class="n">6</span>,<span class="n">8</span>]] <span class="o">*</span> <span class="t">Matrix</span>.identity(<span class="n">2</span>)
<span class="c"># =&gt; [ 2, 4,</span>
<span class="c"># 6, 8 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L891" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="**(other)-instance-method">
<div class="signature">
def <strong>**</strong>(other)
<a class="method-permalink" href="#%2A%2A%28other%29-instance-method">#</a>
</div>
<div class="doc"><p>Matrix exponentiation.</p>
<p>Equivalent to multiplying the matrix by itself N times.
Non integer exponents will be handled by diagonalizing the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]] <span class="o">**</span> <span class="n">2</span>
<span class="c"># =&gt; [ 67, 96,</span>
<span class="c"># 48, 99 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1061" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="+(other:Matrix|Indexable)-instance-method">
<div class="signature">
def <strong>+</strong>(other : <a href="../../Apatite/LinearAlgebra/Matrix.html">Matrix</a> | Indexable)
<a class="method-permalink" href="#%2B%28other%3AMatrix%7CIndexable%29-instance-method">#</a>
</div>
<div class="doc"><p>Matrix addition</p>
<pre><code><span class="t">Matrix</span>.scalar(<span class="n">2</span>,<span class="n">5</span>) <span class="o">+</span> <span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">0</span>], [<span class="n">-4</span>,<span class="n">7</span>]]
<span class="c"># =&gt; [ 6, 0,</span>
<span class="c"># -4, 1 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L924" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="-(other:Matrix|Indexable)-instance-method">
<div class="signature">
def <strong>-</strong>(other : <a href="../../Apatite/LinearAlgebra/Matrix.html">Matrix</a> | Indexable)
<a class="method-permalink" href="#-%28other%3AMatrix%7CIndexable%29-instance-method">#</a>
</div>
<div class="doc"><p>Matrix subtraction</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">5</span>], [<span class="n">4</span>,<span class="n">2</span>]] <span class="o">-</span> <span class="t">Matrix</span>[[<span class="n">9</span>,<span class="n">3</span>], [<span class="n">-4</span>,<span class="n">1</span>]]
<span class="c"># =&gt; [-8, 2,</span>
<span class="c"># 8, 1 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L951" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="/(other)-instance-method">
<div class="signature">
def <strong>/</strong>(other)
<a class="method-permalink" href="#%2F%28other%29-instance-method">#</a>
</div>
<div class="doc"><p>Matrix division (multiplication by the inverse).</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]] <span class="o">/</span> <span class="t">Matrix</span>[[<span class="n">2</span>,<span class="n">9</span>], [<span class="n">3</span>,<span class="n">1</span>]]
<span class="c"># =&gt; [ -7, 1,</span>
<span class="c"># -3, -6 ]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L978" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="==(other:Matrix)-instance-method">
<div class="signature">
def <strong>==</strong>(other : <a href="../../Apatite/LinearAlgebra/Matrix.html">Matrix</a>)
<a class="method-permalink" href="#%3D%3D%28other%3AMatrix%29-instance-method">#</a>
</div>
<div class="doc"><p>Equality operator</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L868" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="[](i)-instance-method">
2019-07-10 01:18:01 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>[]</strong>(i)
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#%5B%5D%28i%29-instance-method">#</a>
2019-07-10 01:18:01 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns row <code>i</code> of the matrix as an Array. Raises if the
index is not found.</p></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L279" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="[](i,j)-instance-method">
2019-07-10 01:18:01 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>[]</strong>(i, j)
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#%5B%5D%28i%2Cj%29-instance-method">#</a>
2019-07-10 01:18:01 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns element (<code>i</code>, <code>j</code>) of the matrix. That is: row <code>i</code>, column <code>j</code>.
Raises if either index is not found.</p></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L291" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="[]=(i,j,v:T)-instance-method">
<div class="signature">
def <strong>[]=</strong>(i, j, v : T)
<a class="method-permalink" href="#%5B%5D%3D%28i%2Cj%2Cv%3AT%29-instance-method">#</a>
</div>
<div class="doc"><p>Set the value at index (<code>i</code>, <code>j</code>). That is: row <code>i</code>, column <code>j</code>.</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L302" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="[]?(i)-instance-method">
2019-07-10 01:18:01 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>[]?</strong>(i)
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#%5B%5D%3F%28i%29-instance-method">#</a>
2019-07-10 01:18:01 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns row <code>i</code> of the matrix as an Array. Returns nil if the
index is not found.</p></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L285" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="[]?(i,j)-instance-method">
2019-07-10 01:18:01 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>[]?</strong>(i, j)
2019-07-10 01:18:01 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#%5B%5D%3F%28i%2Cj%29-instance-method">#</a>
2019-07-10 01:18:01 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns element (<code>i</code>, <code>j</code>) of the matrix. That is: row <code>i</code>, column <code>j</code>.
Returns nil if either index is not found.</p></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L297" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="adjugate-instance-method">
<div class="signature">
def <strong>adjugate</strong>
<a class="method-permalink" href="#adjugate-instance-method">#</a>
</div>
<div class="doc"><p>Returns the adjugate of the matrix.</p>
<p>Matrix[ [7,6],[3,9] ].adjugate</p>
<h1>=> [ 9, -6,</h1>
<h1>-3, 7 ]</h1>
<pre><code></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L626" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="clone-instance-method">
<div class="signature">
def <strong>clone</strong>
<a class="method-permalink" href="#clone-instance-method">#</a>
</div>
<div class="doc"><p>Returns a clone of the matrix, so that the contents of each do not reference
identical objects.</p>
<p>There should be no good reason to do this since Matrices are immutable.</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L876" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="coerce(klass)-instance-method">
<div class="signature">
def <strong>coerce</strong>(klass)
<a class="method-permalink" href="#coerce%28klass%29-instance-method">#</a>
</div>
<div class="doc"><p>Attempt to coerce the elements in the matrix to another type.</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1365" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="cofactor(row,column)-instance-method">
<div class="signature">
def <strong>cofactor</strong>(row, column)
<a class="method-permalink" href="#cofactor%28row%2Ccolumn%29-instance-method">#</a>
</div>
<div class="doc"><p>Returns the (row, column) cofactor which is obtained by multiplying
the first minor by (-1)**(row + column).</p>
<pre><code><span class="t">Matrix</span>.diagonal(<span class="n">9</span>, <span class="n">5</span>, <span class="n">-3</span>, <span class="n">4</span>).cofactor(<span class="n">1</span>, <span class="n">1</span>)
<span class="c"># =&gt; -108</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L612" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="column(j)-instance-method">
2019-07-10 01:18:01 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>column</strong>(j)
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#column%28j%29-instance-method">#</a>
2019-07-10 01:18:01 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns column vector <code>j</code> of the Matrix as a Vector (starting at 0).
Raises if the column doesn't exist.</p></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L336" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="column(j,&amp;block:T-&gt;)-instance-method">
2019-07-10 01:18:01 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>column</strong>(j, &block : T -> )
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#column%28j%2C%26block%3AT-%3E%29-instance-method">#</a>
2019-07-10 01:18:01 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns a block which yields every item in column <code>j</code> of the Matrix.</p></div>
2019-07-10 01:18:01 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L353" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="column?(j)-instance-method">
<div class="signature">
def <strong>column?</strong>(j)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#column%3F%28j%29-instance-method">#</a>
</div>
<div class="doc"><p>Returns column vector <code>j</code> of the Matrix as a Vector (starting at 0).
Returns nil if the column doesn't exist.</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L346" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="column_count:Int32-instance-method">
<div class="signature">
def <strong>column_count</strong> : Int32
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#column_count%3AInt32-instance-method">#</a>
</div>
<div class="doc"><p>Returns the number of columns.</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L314" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="column_vectors-instance-method">
<div class="signature">
def <strong>column_vectors</strong>
<a class="method-permalink" href="#column_vectors-instance-method">#</a>
</div>
<div class="doc"><p>Returns an array of the column vectors of the matrix. See <code><a href="../../Apatite/LinearAlgebra/Vector.html">Vector</a></code>.</p></div>
<br/>
<div>
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1378" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="combine(*matrices,&amp;block)-instance-method">
<div class="signature">
def <strong>combine</strong>(*matrices, &block)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#combine%28%2Amatrices%2C%26block%29-instance-method">#</a>
</div>
<div class="doc"><p>Create a matrix by combining matrices entrywise, using the given block</p>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<pre><code>x <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">6</span>, <span class="n">6</span>], [<span class="n">4</span>, <span class="n">4</span>]]
y <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
<span class="t">Matrix</span>.combine(x, y) {<span class="o">|</span>a, b<span class="o">|</span> a <span class="o">-</span> b}
<span class="c"># =&gt; Matrix[[5, 4], [1, 0]]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L264" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="conj-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>conj</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#conj-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the conjugate of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="t">Complex</span>(<span class="n">1</span>,<span class="n">2</span>), <span class="t">Complex</span>(<span class="n">0</span>,<span class="n">1</span>), <span class="n">0</span>], [<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>]]
<span class="c"># =&gt; 1+2i i 0</span>
<span class="c"># 1 2 3</span>
<span class="t">Matrix</span>[[<span class="t">Complex</span>(<span class="n">1</span>,<span class="n">2</span>), <span class="t">Complex</span>(<span class="n">0</span>,<span class="n">1</span>), <span class="n">0</span>], [<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>]].conj
<span class="c"># =&gt; 1-2i -i 0</span>
<span class="c"># 1 2 3</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1313" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="determinant-instance-method">
<div class="signature">
def <strong>determinant</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#determinant-instance-method">#</a>
</div>
<div class="doc"><p>Returns the determinant of the matrix.</p>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<p>Beware that using Float values can yield erroneous results
because of their lack of precision.
Consider using exact types like Rational or BigDecimal instead.</p>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]].determinant
<span class="c"># =&gt; 45</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1079" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="diagonal?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>diagonal?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#diagonal%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a diagonal matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L697" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="each(which=:all,&amp;block:T-&gt;)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>each</strong>(which = <span class="n">:all</span>, &block : T -> )
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#each%28which%3D%3Aall%2C%26block%3AT-%3E%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Yields all elements of the matrix, starting with those of the first row,
or returns an Enumerator if no block given.
Elements can be restricted by passing an argument:</p>
<ul><li>:all (default): yields all elements</li><li>:diagonal: yields only elements on the diagonal</li><li>:off_diagonal: yields all elements except on the diagonal</li><li>:lower: yields only elements on or below the diagonal</li><li>:strict_lower: yields only elements below the diagonal</li><li>:strict_upper: yields only elements above the diagonal</li><li>:upper: yields only elements on or above the diagonal</li></ul>
<pre><code><span class="t">Matrix</span>[ [<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>] ].each { <span class="o">|</span>e<span class="o">|</span> puts e }
<span class="c"># =&gt; prints the numbers 1 to 4</span>
<span class="t">Matrix</span>[ [<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>] ].each(<span class="n">:strict_lower</span>).to_a <span class="c"># =&gt; [3]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L380" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="each_with_index(which=:all,&amp;block:T,Int32,Int32-&gt;)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>each_with_index</strong>(which = <span class="n">:all</span>, &block : T, Int32, Int32 -> )
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#each_with_index%28which%3D%3Aall%2C%26block%3AT%2CInt32%2CInt32-%3E%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Same as #each, but the row index and column index in addition to the element</p>
<pre><code><span class="t">Matrix</span>[ [<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>] ].each_with_index <span class="k">do</span> <span class="o">|</span>e, row, col<span class="o">|</span>
puts <span class="s">&quot;</span><span class="i">#{</span>e<span class="i">}</span><span class="s"> at </span><span class="i">#{</span>row<span class="i">}</span><span class="s">, </span><span class="i">#{</span>col<span class="i">}</span><span class="s">&quot;</span>
<span class="k">end</span>
<span class="c"># =&gt; Prints:</span>
<span class="c"># 1 at 0, 0</span>
<span class="c"># 2 at 0, 1</span>
<span class="c"># 3 at 1, 0</span>
<span class="c"># 4 at 1, 1</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L438" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="eigensystem-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>eigensystem</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#eigensystem-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the Eigensystem of the matrix
2019-07-10 02:08:46 +00:00
See <code><a href="../../Apatite/LinearAlgebra/Matrix/EigenvalueDecomposition.html">EigenvalueDecomposition</a></code>.</p>
2019-07-10 01:18:01 +00:00
<p><span class="flag purple">NOTE</span> Not working yet</p>
<pre><code>m <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
v, d, v_inv <span class="o">=</span> m.eigensystem
d.diagonal? <span class="c"># =&gt; true</span>
v.inv <span class="o">==</span> v_inv <span class="c"># =&gt; true</span>
(v <span class="o">*</span> d <span class="o">*</span> v_inv).round(<span class="n">5</span>) <span class="o">==</span> m <span class="c"># =&gt; true</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1277" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="empty?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>empty?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#empty%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns true if this matrix is empty.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L705" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="first_minor(row,column)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>first_minor</strong>(row, column)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#first_minor%28row%2Ccolumn%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the submatrix obtained by deleting the specified row and column.</p>
<pre><code><span class="t">Matrix</span>.diagonal(<span class="n">9</span>, <span class="n">5</span>, <span class="n">-3</span>, <span class="n">4</span>).first_minor(<span class="n">1</span>, <span class="n">2</span>)
<span class="c"># =&gt; [ 9, 0, 0,</span>
<span class="c"># 0, 0, 0,</span>
<span class="c"># 0, 0, 4 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L585" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="hadamard_product(m)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>hadamard_product</strong>(m)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#hadamard_product%28m%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Hadamard product</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>]].hadamard_product <span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">2</span>]]
<span class="c"># =&gt; [ 1, 4,</span>
<span class="c"># 9, 8 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L999" target="_blank">View source</a>]
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="hermitian?-instance-method">
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>hermitian?</strong>
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#hermitian%3F-instance-method">#</a>
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is an hermitian matrix.</p></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L710" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="hstack(*matrices)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>hstack</strong>(*matrices)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#hstack%28%2Amatrices%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a new matrix resulting by stacking horizontally
the receiver with the given matrices</p>
<pre><code>x <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
y <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">5</span>, <span class="n">6</span>], [<span class="n">7</span>, <span class="n">8</span>]]
x.hstack(y) <span class="c"># =&gt; Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1161" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="imag-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>imag</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#imag-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the imaginary part of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="t">Complex</span>(<span class="n">1</span>,<span class="n">2</span>), <span class="t">Complex</span>(<span class="n">0</span>,<span class="n">1</span>), <span class="n">0</span>], [<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>]]
<span class="c"># =&gt; [ 1+2i, i, 0,</span>
<span class="c"># 1, 2, 3 ]</span>
<span class="t">Matrix</span>[[<span class="t">Complex</span>(<span class="n">1</span>,<span class="n">2</span>), <span class="t">Complex</span>(<span class="n">0</span>,<span class="n">1</span>), <span class="n">0</span>], [<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>]].imag
<span class="c"># =&gt; [ 2i, i, 0,</span>
<span class="c"># 0, 0, 0 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1328" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="index(i,selector=:all)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>index</strong>(i, selector = <span class="n">:all</span>)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#index%28i%2Cselector%3D%3Aall%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>The index method is specialized to return the index as {row, column}
It also accepts an optional <code>selector</code> argument, see <code><a href="../../Apatite/LinearAlgebra/Matrix.html#each%28which%3D%3Aall%2C%26block%3AT-%3E%29-instance-method">#each</a></code> for details.</p>
<pre><code><span class="t">Matrix</span>[ [<span class="n">1</span>,<span class="n">1</span>], [<span class="n">1</span>,<span class="n">1</span>] ].index(<span class="n">1</span>, <span class="n">:strict_lower</span>)
<span class="c"># =&gt; {1, 0}</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L495" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="index(selector=:all,&amp;block:T-&gt;Bool)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>index</strong>(selector = <span class="n">:all</span>, &block : T -> Bool)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#index%28selector%3D%3Aall%2C%26block%3AT-%3EBool%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the index as {row, column}, using <code>&block</code> to filter the
result. It also accepts an optional <code>selector</code> argument, see
<code><a href="../../Apatite/LinearAlgebra/Matrix.html#each%28which%3D%3Aall%2C%26block%3AT-%3E%29-instance-method">#each</a></code> for details.</p>
<pre><code><span class="t">Matrix</span>[ [<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>] ].index(<span class="o">&amp;</span>.even?)
<span class="c"># =&gt; {0, 1}</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L514" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="inverse-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>inverse</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#inverse-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the inverse of the matrix.</p>
<p><span class="flag purple">NOTE</span> Always returns a <code>Float64</code> regardless of <code>T</code>s type. To coerce
back into an <code>Int</code>, use <code><a href="../../Apatite/LinearAlgebra/Matrix.html#coerce%28klass%29-instance-method">#coerce</a></code>.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">-1</span>, <span class="n">-1</span>], [<span class="n">0</span>, <span class="n">-1</span>]].inverse
<span class="c"># =&gt; [ -1.0, 1.0,</span>
<span class="c"># 0.0, -1.0 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1013" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="laplace_expansion(*,row=nil,column=nil)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>laplace_expansion</strong>(*, row = <span class="n">nil</span>, column = <span class="n">nil</span>)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#laplace_expansion%28%2A%2Crow%3Dnil%2Ccolumn%3Dnil%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the Laplace expansion along given row or column.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]].laplace_expansion(column: <span class="n">1</span>)
<span class="c"># =&gt; 45</span>
<span class="t">Matrix</span>[[<span class="t">Vector</span>[<span class="n">1</span>, <span class="n">0</span>], <span class="t">Vector</span>[<span class="n">0</span>, <span class="n">1</span>]], [<span class="n">2</span>, <span class="n">3</span>]].laplace_expansion(row: <span class="n">0</span>)
<span class="c"># =&gt; Vector[3, -2]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L642" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="lower_triangular?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>lower_triangular?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#lower_triangular%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns true if this matrix is a lower triangular matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L720" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="lup-instance-method">
<div class="signature">
def <strong>lup</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#lup-instance-method">#</a>
</div>
<div class="doc"><p>Returns the LUP decomposition of the matrix
See +LUPDecomposition+.</p>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<p><span class="flag purple">NOTE</span> Not working yet</p>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<pre><code>a <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
l, u, p <span class="o">=</span> a.lup
l.lower_triangular? <span class="c"># =&gt; true</span>
u.upper_triangular? <span class="c"># =&gt; true</span>
p.permutation? <span class="c"># =&gt; true</span>
l <span class="o">*</span> u <span class="o">==</span> p <span class="o">*</span> a <span class="c"># =&gt; true</span>
a.lup.solve([<span class="n">2</span>, <span class="n">5</span>]) <span class="c"># =&gt; Vector[(1/1), (1/2)]</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1295" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="map(&amp;block:T-&gt;T)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>map</strong>(&block : T -> T)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#map%28%26block%3AT-%3ET%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a Matrix that is the result of iteration of the given block
over all elements in the matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L359" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="minor(from_row:Int,nrows:Int,from_col:Int,ncols:Int)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>minor</strong>(from_row : Int, nrows : Int, from_col : Int, ncols : Int)
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#minor%28from_row%3AInt%2Cnrows%3AInt%2Cfrom_col%3AInt%2Cncols%3AInt%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a section of the Matrix.</p>
2019-07-10 02:22:15 +00:00
<pre><code><span class="t">Matrix</span>.diagonal(<span class="n">9</span>, <span class="n">5</span>, <span class="n">-3</span>).minor(<span class="n">0</span>, <span class="n">2</span>, <span class="n">0</span>, <span class="n">3</span>)
2019-07-10 01:18:01 +00:00
<span class="c"># =&gt; [ 9, 0, 0,</span>
<span class="c"># 0, 5, 0 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L563" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 02:22:15 +00:00
<div class="entry-detail" id="minor(row_range:Range,col_range:Range)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 02:22:15 +00:00
def <strong>minor</strong>(row_range : Range, col_range : Range)
2019-06-13 02:23:54 +00:00
2019-07-10 02:22:15 +00:00
<a class="method-permalink" href="#minor%28row_range%3ARange%2Ccol_range%3ARange%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a section of the Matrix.</p>
2019-07-10 02:22:15 +00:00
<pre><code><span class="t">Matrix</span>.diagonal(<span class="n">9</span>, <span class="n">5</span>, <span class="n">-3</span>).minor(<span class="n">0</span>..<span class="n">1</span>, <span class="n">0</span>..<span class="n">2</span>)
2019-07-10 01:18:01 +00:00
<span class="c"># =&gt; [ 9, 0, 0,</span>
<span class="c"># 0, 5, 0 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L532" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="normal?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>normal?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#normal%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a normal matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">1</span>, <span class="n">0</span>], [<span class="n">0</span>, <span class="n">1</span>, <span class="n">1</span>], [<span class="n">1</span>, <span class="n">0</span>, <span class="n">1</span>]].normal?
<span class="c"># =&gt; true</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L732" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="orthogonal?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>orthogonal?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#orthogonal%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is an orthogonal matrix</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">0</span>], [<span class="n">0</span>, <span class="n">1</span>]].orthogonal?
<span class="c"># =&gt; true</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L752" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="permutation?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>permutation?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#permutation%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a permutation matrix</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">0</span>], [<span class="n">0</span>, <span class="n">1</span>]].permutation?
<span class="c"># =&gt; true</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L772" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="pretty_print(pp):Nil-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>pretty_print</strong>(pp) : Nil
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#pretty_print%28pp%29%3ANil-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1414" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="rank-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>rank</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#rank-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the rank of the matrix.</p>
<p>Beware that using Float values can yield erroneous results
because of their lack of precision.
Consider using exact types like Rational or BigDecimal instead.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]].rank
<span class="c"># =&gt; 2</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1175" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="real-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>real</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#real-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the real part of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="t">Complex</span>(<span class="n">1</span>,<span class="n">2</span>), <span class="t">Complex</span>(<span class="n">0</span>,<span class="n">1</span>), <span class="n">0</span>], [<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>]]
<span class="c"># =&gt; [ 1+2i, i, 0,</span>
<span class="c"># 1, 2, 3 ]</span>
<span class="t">Matrix</span>[[<span class="t">Complex</span>(<span class="n">1</span>,<span class="n">2</span>), <span class="t">Complex</span>(<span class="n">0</span>,<span class="n">1</span>), <span class="n">0</span>], [<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>]].real
<span class="c"># =&gt; [ 1, 0, 0,</span>
<span class="c"># 1, 2, 3 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1343" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="real?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>real?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#real%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this matrix contains real numbers,
i.e. not <code>Complex</code>.</p>
<pre><code><span class="k">require</span> <span class="s">&quot;complex&quot;</span>
<span class="t">Matrix</span>[[<span class="t">Complex</span>.<span class="k">new</span>(<span class="n">1</span>, <span class="n">0</span>)], [<span class="t">Complex</span>.<span class="k">new</span>(<span class="n">0</span>, <span class="n">1</span>)]].real?
<span class="c"># =&gt; false</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L798" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="rect-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>rect</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#rect-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns an array containing matrices corresponding to the real and imaginary
parts of the matrix</p>
<pre><code>m.rect <span class="o">==</span> [m.real, m.imag]
<span class="c"># ==&gt; true for all matrices m</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1355" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="regular?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>regular?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#regular%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a regular (i.e. non-singular) matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L803" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="round(n=0)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>round</strong>(n = <span class="n">0</span>)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#round%28n%3D0%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a matrix with entries rounded to the given precision
(see <code>Float#round</code>)</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1205" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="row(i,&amp;block:Vector-&gt;)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>row</strong>(i, &block : <a href="../../Apatite/LinearAlgebra/Vector.html">Vector</a> -> )
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#row%28i%2C%26block%3AVector-%3E%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a block which yields every Vector in the row (starting at 0).</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L322" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="row(i)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>row</strong>(i)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#row%28i%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns row vector number <code>i</code> of the Matrix as a Vector (starting
at 0 like a good boy). Raises if the row doesn't exist.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L316" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="row?(i)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>row?</strong>(i)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#row%3F%28i%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns row vector number <code>i</code> of the Matrix as a Vector (starting
at 0 like a good boy). Returns nil if the row doesn't exist.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L328" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="row_count-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>row_count</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#row_count-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the number of rows.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L307" target="_blank">View source</a>]
</div>
</div>
<div class="entry-detail" id="row_vectors-instance-method">
<div class="signature">
def <strong>row_vectors</strong>
<a class="method-permalink" href="#row_vectors-instance-method">#</a>
</div>
<div class="doc"><p>Returns an array of the row vectors of the matrix. See <code><a href="../../Apatite/LinearAlgebra/Vector.html">Vector</a></code>.</p></div>
<br/>
<div>
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1371" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="singular?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>singular?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#singular%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a singular matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L808" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="square?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>square?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#square%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a square matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L813" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="swap_columns(col1,col2)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>swap_columns</strong>(col1, col2)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#swap_columns%28col1%2Ccol2%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Swaps <code>col1</code> and <code>col2</code></p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L680" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="swap_rows(row1,row2)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>swap_rows</strong>(row1, row2)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#swap_rows%28row1%2Crow2%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Swaps <code>row1</code> and <code>row2</code></p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L668" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="symmetric?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>symmetric?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#symmetric%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns +true+ if this is a symmetric matrix.
Raises an error if matrix is not square.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L820" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="t-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>t</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#t-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the transpose of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>], [<span class="n">5</span>,<span class="n">6</span>]]
<span class="c"># =&gt; [ 1, 2,</span>
<span class="c"># 3, 4,</span>
<span class="c"># 5, 6 ]</span>
<span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>], [<span class="n">5</span>,<span class="n">6</span>]].transpose
<span class="c"># =&gt; [ 1, 3, 5,</span>
<span class="c"># 2, 4, 6 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1244" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="to_a-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>to_a</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#to_a-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Returns an array of arrays that describe the rows of the matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1385" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="to_json(json:JSON::Builder)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>to_json</strong>(json : JSON::Builder)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#to_json%28json%3AJSON%3A%3ABuilder%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 02:22:15 +00:00
<div class="doc"><p>Convert the matrix to a json array</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1390" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="to_s(io)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>to_s</strong>(io)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#to_s%28io%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1400" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="tr-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>tr</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#tr-instance-method">#</a>
</div>
<div class="doc"><p>Returns the trace (sum of diagonal elements) of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]].trace
<span class="c"># =&gt; 16</span></code></pre></div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1223" target="_blank">View source</a>]
2019-07-10 01:18:01 +00:00
</div>
</div>
<div class="entry-detail" id="trace-instance-method">
<div class="signature">
def <strong>trace</strong>
<a class="method-permalink" href="#trace-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the trace (sum of diagonal elements) of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">7</span>,<span class="n">6</span>], [<span class="n">3</span>,<span class="n">9</span>]].trace
<span class="c"># =&gt; 16</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1215" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="transpose-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>transpose</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#transpose-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns the transpose of the matrix.</p>
<pre><code><span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>], [<span class="n">5</span>,<span class="n">6</span>]]
<span class="c"># =&gt; [ 1, 2,</span>
<span class="c"># 3, 4,</span>
<span class="c"># 5, 6 ]</span>
<span class="t">Matrix</span>[[<span class="n">1</span>,<span class="n">2</span>], [<span class="n">3</span>,<span class="n">4</span>], [<span class="n">5</span>,<span class="n">6</span>]].transpose
<span class="c"># =&gt; [ 1, 3, 5,</span>
<span class="c"># 2, 4, 6 ]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1238" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="unitary?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>unitary?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#unitary%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a unitary matrix</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L832" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="unsafe_fetch(i)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>unsafe_fetch</strong>(i)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#unsafe_fetch%28i%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1423" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="upper_triangular?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>upper_triangular?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#upper_triangular%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns true if this matrix is a upper triangular matrix.</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L852" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="vstack(*matrices)-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>vstack</strong>(*matrices)
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#vstack%28%2Amatrices%29-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns a new matrix resulting by stacking vertically
the receiver with the given matrices</p>
<pre><code>x <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">1</span>, <span class="n">2</span>], [<span class="n">3</span>, <span class="n">4</span>]]
y <span class="o">=</span> <span class="t">Matrix</span>[[<span class="n">5</span>, <span class="n">6</span>], [<span class="n">7</span>, <span class="n">8</span>]]
x.vstack(y)
<span class="c"># =&gt; Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]</span></code></pre></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L1257" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
2019-07-10 01:18:01 +00:00
<div class="entry-detail" id="zero?-instance-method">
2019-06-13 02:23:54 +00:00
<div class="signature">
2019-07-10 01:18:01 +00:00
def <strong>zero?</strong>
2019-06-13 02:23:54 +00:00
2019-07-10 01:18:01 +00:00
<a class="method-permalink" href="#zero%3F-instance-method">#</a>
2019-06-13 02:23:54 +00:00
</div>
2019-07-10 01:18:01 +00:00
<div class="doc"><p>Returns <code>true</code> if this is a matrix with only zero elements</p></div>
2019-06-13 02:23:54 +00:00
<br/>
<div>
2019-07-10 02:22:15 +00:00
[<a href="https://github.com/watzon/apatite/blob/6e67ceb81b0b3c61d48b74e5ca5154866a9abd1a/src/apatite/linear_algebra/matrix.cr#L859" target="_blank">View source</a>]
2019-06-13 02:23:54 +00:00
</div>
</div>
</div>
</body>
</html>