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
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
assignColumn, assignRow, getQuick, like, like, setQuick
forEach, spliterator
protected int rows
protected int columns
public static final int COL
public static final int ROW
public int columnSize()
columnSize
in interface Matrix
public int rowSize()
public Iterator<MatrixSlice> iterator()
iterator
in interface Iterable<MatrixSlice>
public Iterator<MatrixSlice> iterateAll()
iterateAll
in interface VectorIterable
public Iterator<MatrixSlice> iterateNonEmpty()
iterateNonEmpty
in interface VectorIterable
public int numSlices()
numSlices
in interface VectorIterable
public double get(String rowLabel, String columnLabel)
Matrix
public Map<String,Integer> getColumnLabelBindings()
Matrix
getColumnLabelBindings
in interface Matrix
Map<String, Integer>
public Map<String,Integer> getRowLabelBindings()
Matrix
getRowLabelBindings
in interface Matrix
Map<String, Integer>
public void set(String rowLabel, double[] rowData)
Matrix
public void set(String rowLabel, int row, double[] rowData)
Matrix
public void set(String rowLabel, String columnLabel, double value)
Matrix
public void set(String rowLabel, String columnLabel, int row, int column, double value)
Matrix
public void setColumnLabelBindings(Map<String,Integer> bindings)
Matrix
setColumnLabelBindings
in interface Matrix
bindings
- a Map<String, Integer>
of label bindingspublic void setRowLabelBindings(Map<String,Integer> bindings)
Matrix
setRowLabelBindings
in interface Matrix
bindings
- a Map<String, Integer>
of label bindingspublic int numRows()
numRows
in interface VectorIterable
public int numCols()
numCols
in interface VectorIterable
public String asFormatString()
asFormatString
in interface Matrix
public Matrix assign(double value)
Matrix
public Matrix assign(double[][] values)
Matrix
public Matrix assign(Matrix other, DoubleDoubleFunction function)
Matrix
public Matrix assign(Matrix other)
Matrix
public Matrix assign(DoubleFunction function)
Matrix
public Vector aggregateRows(VectorFunction f)
aggregateRows
in interface Matrix
f
- The function to be applied to each row.public Vector viewRow(int row)
public Vector viewColumn(int column)
viewColumn
in interface Matrix
column
- Which column to return.public Vector viewDiagonal()
viewDiagonal
in interface Matrix
public double aggregate(DoubleDoubleFunction combiner, DoubleFunction mapper)
public Vector aggregateColumns(VectorFunction f)
aggregateColumns
in interface Matrix
f
- The function to be applied to each column.public double determinant()
Matrix
determinant
in interface Matrix
public Matrix clone()
Matrix
public Matrix divide(double x)
Matrix
public double get(int row, int column)
Matrix
public Matrix minus(Matrix other)
Matrix
public Matrix plus(double x)
Matrix
public Matrix plus(Matrix other)
Matrix
public void set(int row, int column, double value)
Matrix
public Matrix times(double x)
Matrix
public Matrix times(Matrix other)
Matrix
public Vector times(Vector v)
VectorIterable
times
in interface VectorIterable
v
- a vector with cardinality equal to getNumCols() of the recipientpublic Vector timesSquared(Vector v)
VectorIterable
timesSquared
in interface VectorIterable
v
- a vector with cardinality equal to getNumCols() of the recipientpublic Matrix transpose()
Matrix
public Matrix viewPart(int rowOffset, int rowsRequested, int columnOffset, int columnsRequested)
Matrix
viewPart
in interface Matrix
rowOffset
- 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)
Matrix
public double zSum()
Matrix
public int[] getNumNondefaultElements()
Matrix
getNumNondefaultElements
in interface Matrix
public MatrixFlavor getFlavor()
Matrix
UnsupportedOperationException
.Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.