<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_51) on Wed Sep 16 15:55:11 PDT 2015 -->
<title>Matrix</title>
<meta name="date" content="2015-09-16">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Matrix";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/spark/mllib/linalg/Matrices.html" title="class in org.apache.spark.mllib.linalg"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/spark/mllib/linalg/QRDecomposition.html" title="class in org.apache.spark.mllib.linalg"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/spark/mllib/linalg/Matrix.html" target="_top">Frames</a></li>
<li><a href="Matrix.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.spark.mllib.linalg</div>
<h2 title="Interface Matrix" class="title">Interface Matrix</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Superinterfaces:</dt>
<dd>java.io.Serializable</dd>
</dl>
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../../org/apache/spark/mllib/linalg/DenseMatrix.html" title="class in org.apache.spark.mllib.linalg">DenseMatrix</a>, <a href="../../../../../org/apache/spark/mllib/linalg/SparseMatrix.html" title="class in org.apache.spark.mllib.linalg">SparseMatrix</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="strong">Matrix</span>
extends scala.Serializable</pre>
<div class="block">Trait for a local matrix.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#apply(int, int)">apply</a></strong>(int i,
int j)</code>
<div class="block">Gets the (i, j)-th element.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#copy()">copy</a></strong>()</code>
<div class="block">Get a deep copy of the matrix.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#foreachActive(scala.Function3)">foreachActive</a></strong>(scala.Function3<java.lang.Object,java.lang.Object,java.lang.Object,scala.runtime.BoxedUnit> f)</code>
<div class="block">Applies a function <code>f</code> to all the active elements of dense and sparse matrix.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#index(int, int)">index</a></strong>(int i,
int j)</code>
<div class="block">Return the index for the (i, j)-th element in the backing array.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#isTransposed()">isTransposed</a></strong>()</code>
<div class="block">Flag that keeps track whether the matrix is transposed or not.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#map(scala.Function1)">map</a></strong>(scala.Function1<java.lang.Object,java.lang.Object> f)</code>
<div class="block">Map the values of this matrix using a function.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/DenseMatrix.html" title="class in org.apache.spark.mllib.linalg">DenseMatrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#multiply(org.apache.spark.mllib.linalg.DenseMatrix)">multiply</a></strong>(<a href="../../../../../org/apache/spark/mllib/linalg/DenseMatrix.html" title="class in org.apache.spark.mllib.linalg">DenseMatrix</a> y)</code>
<div class="block">Convenience method for `Matrix`-`DenseMatrix` multiplication.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/DenseVector.html" title="class in org.apache.spark.mllib.linalg">DenseVector</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#multiply(org.apache.spark.mllib.linalg.DenseVector)">multiply</a></strong>(<a href="../../../../../org/apache/spark/mllib/linalg/DenseVector.html" title="class in org.apache.spark.mllib.linalg">DenseVector</a> y)</code>
<div class="block">Convenience method for `Matrix`-`DenseVector` multiplication.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/DenseVector.html" title="class in org.apache.spark.mllib.linalg">DenseVector</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#multiply(org.apache.spark.mllib.linalg.Vector)">multiply</a></strong>(<a href="../../../../../org/apache/spark/mllib/linalg/Vector.html" title="interface in org.apache.spark.mllib.linalg">Vector</a> y)</code>
<div class="block">Convenience method for `Matrix`-`Vector` multiplication.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#numActives()">numActives</a></strong>()</code>
<div class="block">Find the number of values stored explicitly.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#numCols()">numCols</a></strong>()</code>
<div class="block">Number of columns.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#numNonzeros()">numNonzeros</a></strong>()</code>
<div class="block">Find the number of non-zero active values.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#numRows()">numRows</a></strong>()</code>
<div class="block">Number of rows.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>double[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#toArray()">toArray</a></strong>()</code>
<div class="block">Converts to a dense array in column major.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>breeze.linalg.Matrix<java.lang.Object></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#toBreeze()">toBreeze</a></strong>()</code>
<div class="block">Converts to a breeze matrix.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#toString()">toString</a></strong>()</code>
<div class="block">A human readable representation of the matrix</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#toString(int, int)">toString</a></strong>(int maxLines,
int maxLineWidth)</code>
<div class="block">A human readable representation of the matrix with maximum lines and width</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#transpose()">transpose</a></strong>()</code>
<div class="block">Transpose the Matrix.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#update(scala.Function1)">update</a></strong>(scala.Function1<java.lang.Object,java.lang.Object> f)</code>
<div class="block">Update all the values of this matrix using the function f.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html#update(int, int, double)">update</a></strong>(int i,
int j,
double v)</code>
<div class="block">Update element at (i, j)</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="numRows()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>numRows</h4>
<pre>int numRows()</pre>
<div class="block">Number of rows.</div>
</li>
</ul>
<a name="numCols()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>numCols</h4>
<pre>int numCols()</pre>
<div class="block">Number of columns.</div>
</li>
</ul>
<a name="isTransposed()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isTransposed</h4>
<pre>boolean isTransposed()</pre>
<div class="block">Flag that keeps track whether the matrix is transposed or not. False by default.</div>
</li>
</ul>
<a name="toArray()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toArray</h4>
<pre>double[] toArray()</pre>
<div class="block">Converts to a dense array in column major.</div>
</li>
</ul>
<a name="toBreeze()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toBreeze</h4>
<pre>breeze.linalg.Matrix<java.lang.Object> toBreeze()</pre>
<div class="block">Converts to a breeze matrix.</div>
</li>
</ul>
<a name="apply(int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>apply</h4>
<pre>double apply(int i,
int j)</pre>
<div class="block">Gets the (i, j)-th element.</div>
</li>
</ul>
<a name="index(int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>index</h4>
<pre>int index(int i,
int j)</pre>
<div class="block">Return the index for the (i, j)-th element in the backing array.</div>
</li>
</ul>
<a name="update(int, int, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre>void update(int i,
int j,
double v)</pre>
<div class="block">Update element at (i, j)</div>
</li>
</ul>
<a name="copy()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>copy</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a> copy()</pre>
<div class="block">Get a deep copy of the matrix.</div>
</li>
</ul>
<a name="transpose()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>transpose</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a> transpose()</pre>
<div class="block">Transpose the Matrix. Returns a new `Matrix` instance sharing the same underlying data.</div>
</li>
</ul>
<a name="multiply(org.apache.spark.mllib.linalg.DenseMatrix)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>multiply</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/DenseMatrix.html" title="class in org.apache.spark.mllib.linalg">DenseMatrix</a> multiply(<a href="../../../../../org/apache/spark/mllib/linalg/DenseMatrix.html" title="class in org.apache.spark.mllib.linalg">DenseMatrix</a> y)</pre>
<div class="block">Convenience method for `Matrix`-`DenseMatrix` multiplication.</div>
</li>
</ul>
<a name="multiply(org.apache.spark.mllib.linalg.DenseVector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>multiply</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/DenseVector.html" title="class in org.apache.spark.mllib.linalg">DenseVector</a> multiply(<a href="../../../../../org/apache/spark/mllib/linalg/DenseVector.html" title="class in org.apache.spark.mllib.linalg">DenseVector</a> y)</pre>
<div class="block">Convenience method for `Matrix`-`DenseVector` multiplication. For binary compatibility.</div>
</li>
</ul>
<a name="multiply(org.apache.spark.mllib.linalg.Vector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>multiply</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/DenseVector.html" title="class in org.apache.spark.mllib.linalg">DenseVector</a> multiply(<a href="../../../../../org/apache/spark/mllib/linalg/Vector.html" title="interface in org.apache.spark.mllib.linalg">Vector</a> y)</pre>
<div class="block">Convenience method for `Matrix`-`Vector` multiplication.</div>
</li>
</ul>
<a name="toString()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>java.lang.String toString()</pre>
<div class="block">A human readable representation of the matrix</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>toString</code> in class <code>java.lang.Object</code></dd>
</dl>
</li>
</ul>
<a name="toString(int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>java.lang.String toString(int maxLines,
int maxLineWidth)</pre>
<div class="block">A human readable representation of the matrix with maximum lines and width</div>
</li>
</ul>
<a name="map(scala.Function1)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>map</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a> map(scala.Function1<java.lang.Object,java.lang.Object> f)</pre>
<div class="block">Map the values of this matrix using a function. Generates a new matrix. Performs the
function on only the backing array. For example, an operation such as addition or</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - (undocumented)</dd>
<dt><span class="strong">Returns:</span></dt><dd>(undocumented)
subtraction will only be performed on the non-zero values in a <code>SparseMatrix</code>.</dd></dl>
</li>
</ul>
<a name="update(scala.Function1)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>update</h4>
<pre><a href="../../../../../org/apache/spark/mllib/linalg/Matrix.html" title="interface in org.apache.spark.mllib.linalg">Matrix</a> update(scala.Function1<java.lang.Object,java.lang.Object> f)</pre>
<div class="block">Update all the values of this matrix using the function f. Performed in-place on the
backing array. For example, an operation such as addition or subtraction will only be</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - (undocumented)</dd>
<dt><span class="strong">Returns:</span></dt><dd>(undocumented)
performed on the non-zero values in a <code>SparseMatrix</code>.</dd></dl>
</li>
</ul>
<a name="foreachActive(scala.Function3)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>foreachActive</h4>
<pre>void foreachActive(scala.Function3<java.lang.Object,java.lang.Object,java.lang.Object,scala.runtime.BoxedUnit> f)</pre>
<div class="block">Applies a function <code>f</code> to all the active elements of dense and sparse matrix. The ordering
of the elements are not defined.
<p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - the function takes three parameters where the first two parameters are the row
and column indices respectively with the type <code>Int</code>, and the final parameter is the
corresponding value in the matrix with type <code>Double</code>.</dd></dl>
</li>
</ul>
<a name="numNonzeros()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>numNonzeros</h4>
<pre>int numNonzeros()</pre>
<div class="block">Find the number of non-zero active values.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>(undocumented)</dd></dl>
</li>
</ul>
<a name="numActives()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>numActives</h4>
<pre>int numActives()</pre>
<div class="block">Find the number of values stored explicitly. These values can be zero as well.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>(undocumented)</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/spark/mllib/linalg/Matrices.html" title="class in org.apache.spark.mllib.linalg"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/spark/mllib/linalg/QRDecomposition.html" title="class in org.apache.spark.mllib.linalg"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/spark/mllib/linalg/Matrix.html" target="_top">Frames</a></li>
<li><a href="Matrix.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<script defer="defer" type="text/javascript" src="../../../../../lib/jquery.js"></script><script defer="defer" type="text/javascript" src="../../../../../lib/api-javadocs.js"></script></body>
</html>