public abstract class AbstractMatrix extends Object implements Matrix
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractMatrix.TransposeViewVector |
| Modifier and Type | Field and Description |
|---|---|
static int |
COL |
protected Map<String,Integer> |
columnLabelBindings |
protected int |
columns |
static int |
ROW |
protected Map<String,Integer> |
rowLabelBindings |
protected int |
rows |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMatrix(int rows,
int columns) |
| Modifier and Type | Method and Description |
|---|---|
double |
aggregate(DoubleDoubleFunction combiner,
DoubleFunction mapper)
Collects the results of a function applied to each element of a matrix and then aggregated.
|
Vector |
aggregateColumns(VectorFunction f)
Collects the results of a function applied to each column of a matrix.
|
Vector |
aggregateRows(VectorFunction f)
Collects the results of a function applied to each row of a matrix.
|
String |
asFormatString() |
Matrix |
assign(double value)
Assign the value to all elements of the receiver
|
Matrix |
assign(double[][] values)
Assign the values to the receiver
|
Matrix |
assign(DoubleFunction function)
Apply the function to each element of the receiver
|
Matrix |
assign(Matrix other)
Assign the other vector values to the receiver
|
Matrix |
assign(Matrix other,
DoubleDoubleFunction function)
Apply the function to each element of the receiver and the corresponding element of the other argument
|
Matrix |
clone()
Return a copy of the recipient
|
int |
columnSize() |
double |
determinant()
Returns matrix determinator using Laplace theorem
|
Matrix |
divide(double x)
Return a new matrix containing the values of the recipient divided by the argument
|
double |
get(int row,
int column)
Return the value at the given indexes
|
double |
get(String rowLabel,
String columnLabel)
Return the value at the given labels
|
Map<String,Integer> |
getColumnLabelBindings()
Return a map of the current column label bindings of the receiver
|
MatrixFlavor |
getFlavor()
Get matrix structural flavor (operations performance hints).
|
int[] |
getNumNondefaultElements()
Return the number of values in the recipient
|
Map<String,Integer> |
getRowLabelBindings()
Return a map of the current row label bindings of the receiver
|
Iterator<MatrixSlice> |
iterateAll() |
Iterator<MatrixSlice> |
iterateNonEmpty() |
Iterator<MatrixSlice> |
iterator() |
Matrix |
minus(Matrix other)
Return a new matrix containing the element by element difference of the recipient and the argument
|
int |
numCols() |
int |
numRows() |
int |
numSlices()
Abstracted out for the iterator
|
Matrix |
plus(double x)
Return a new matrix containing the sum of each value of the recipient and the argument
|
Matrix |
plus(Matrix other)
Return a new matrix containing the element by element sum of the recipient and the argument
|
int |
rowSize() |
void |
set(int row,
double[] data) |
void |
set(int row,
int column,
double value)
Set the value at the given index
|
void |
set(String rowLabel,
double[] rowData)
Sets the row values at the given row label
|
void |
set(String rowLabel,
int row,
double[] rowData)
Sets the row values at the given row index and updates the row labels
|
void |
set(String rowLabel,
String columnLabel,
double value)
Set the value at the given index
|
void |
set(String rowLabel,
String columnLabel,
int row,
int column,
double value)
Set the value at the given index, updating the row and column label bindings
|
void |
setColumnLabelBindings(Map<String,Integer> bindings)
Sets a map of column label bindings in the receiver
|
void |
setRowLabelBindings(Map<String,Integer> bindings)
Sets a map of row label bindings in the receiver
|
Matrix |
times(double x)
Return a new matrix containing the product of each value of the recipient and the argument
|
Matrix |
times(Matrix other)
Return a new matrix containing the product of the recipient and the argument
|
Vector |
times(Vector v)
Return a new vector with cardinality equal to getNumRows() of this matrix which is the matrix product of the
recipient and the argument
|
Vector |
timesSquared(Vector v)
Convenience method for producing this.transpose().times(this.times(v)), which can be implemented with only one pass
over the matrix, without making the transpose() call (which can be expensive if the matrix is sparse)
|
String |
toString() |
Matrix |
transpose()
Return a new matrix that is the transpose of the receiver
|
Vector |
viewColumn(int column)
Returns a view of a row.
|
Vector |
viewDiagonal()
Provides a view of the diagonal of a matrix.
|
Matrix |
viewPart(int[] offset,
int[] size)
Return a view into part of a matrix.
|
Matrix |
viewPart(int rowOffset,
int rowsRequested,
int columnOffset,
int columnsRequested)
Return a view into part of a matrix.
|
Vector |
viewRow(int row)
Returns a view of a row.
|
double |
zSum()
Return the sum of all the elements of the receiver
|
protected int rows
protected int columns
public static final int COL
public static final int ROW
public int columnSize()
columnSize in interface Matrixpublic int rowSize()
public Iterator<MatrixSlice> iterator()
iterator in interface Iterable<MatrixSlice>public Iterator<MatrixSlice> iterateAll()
iterateAll in interface VectorIterablepublic Iterator<MatrixSlice> iterateNonEmpty()
iterateNonEmpty in interface VectorIterablepublic int numSlices()
numSlices in interface VectorIterablepublic double get(String rowLabel, String columnLabel)
Matrixpublic Map<String,Integer> getColumnLabelBindings()
MatrixgetColumnLabelBindings in interface Matrixpublic Map<String,Integer> getRowLabelBindings()
MatrixgetRowLabelBindings in interface Matrixpublic void set(String rowLabel, double[] rowData)
Matrixpublic void set(String rowLabel, int row, double[] rowData)
Matrixpublic void set(String rowLabel, String columnLabel, double value)
Matrixpublic void set(String rowLabel, String columnLabel, int row, int column, double value)
Matrixpublic void setColumnLabelBindings(Map<String,Integer> bindings)
MatrixsetColumnLabelBindings in interface Matrixbindings - a Mappublic void setRowLabelBindings(Map<String,Integer> bindings)
MatrixsetRowLabelBindings in interface Matrixbindings - a Mappublic int numRows()
numRows in interface VectorIterablepublic int numCols()
numCols in interface VectorIterablepublic String asFormatString()
asFormatString in interface Matrixpublic Matrix assign(double value)
Matrixpublic Matrix assign(double[][] values)
Matrixpublic Matrix assign(Matrix other, DoubleDoubleFunction function)
Matrixpublic Matrix assign(Matrix other)
Matrixpublic Matrix assign(DoubleFunction function)
Matrixpublic Vector aggregateRows(VectorFunction f)
aggregateRows in interface Matrixf - The function to be applied to each row.public Vector viewRow(int row)
public Vector viewColumn(int column)
viewColumn in interface Matrixcolumn - Which column to return.public Vector viewDiagonal()
viewDiagonal in interface Matrixpublic double aggregate(DoubleDoubleFunction combiner, DoubleFunction mapper)
public Vector aggregateColumns(VectorFunction f)
aggregateColumns in interface Matrixf - The function to be applied to each column.public double determinant()
Matrixdeterminant in interface Matrixpublic Matrix clone()
Matrixpublic Matrix divide(double x)
Matrixpublic double get(int row,
int column)
Matrixpublic Matrix minus(Matrix other)
Matrixpublic Matrix plus(double x)
Matrixpublic Matrix plus(Matrix other)
Matrixpublic void set(int row,
int column,
double value)
Matrixpublic Matrix times(double x)
Matrixpublic Matrix times(Matrix other)
Matrixpublic Vector times(Vector v)
VectorIterabletimes in interface VectorIterablev - a vector with cardinality equal to getNumCols() of the recipientpublic Vector timesSquared(Vector v)
VectorIterabletimesSquared in interface VectorIterablev - a vector with cardinality equal to getNumCols() of the recipientpublic Matrix transpose()
Matrixpublic Matrix viewPart(int rowOffset, int rowsRequested, int columnOffset, int columnsRequested)
MatrixviewPart in interface MatrixrowOffset - The first row of the viewrowsRequested - The number of rows in the viewcolumnOffset - The first column in the viewcolumnsRequested - The number of columns in the viewpublic Matrix viewPart(int[] offset, int[] size)
Matrixpublic double zSum()
Matrixpublic int[] getNumNondefaultElements()
MatrixgetNumNondefaultElements in interface Matrixpublic MatrixFlavor getFlavor()
MatrixUnsupportedOperationException.Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.