public final class Matrix extends ADenseArrayMatrix
datacols, rows| Constructor and Description |
|---|
Matrix(AMatrix m)
Creates a new Matrix with a copy of all data from the source matrix
|
Matrix(int rowCount,
int columnCount) |
| Modifier and Type | Method and Description |
|---|---|
void |
abs()
Replaces all elements of this array with their absolute values, according to Math.abs(double)
|
void |
add(AMatrix m)
Adds another matrix to this matrix.
|
void |
add(double d)
Adds a double value to all elements in this array.
|
static void |
add(Matrix dest,
Matrix a,
Matrix b) |
void |
add2(AMatrix a,
AMatrix b)
Adds two matrices to this matrix.
|
void |
add2(Matrix a,
Matrix b) |
void |
addAt(int i,
int j,
double d)
Adds a value at a specific position in the matrix, mutating the matrix
Does not perform bounds checking - this in an unsafe operation
|
void |
addMultiple(ADenseArrayMatrix m,
double factor) |
void |
addMultiple(AMatrix m,
double factor)
Adds a scalar multiple of another matrix to this matrix
|
void |
addRowMultiple(int src,
int dst,
double factor)
Adds a multiple of a source row to a destination row
This is an elementary row operation
|
void |
applyOp(Op op)
Applies a unary operator to all elements of the array (in-place)
|
void |
applyOp(Op2 op,
double b)
Applies a binary operator to this array and a double value.
|
double[] |
asDoubleArray()
Returns the underlying double array representing the densely packed elements of this array
Returns null if there is no such array
|
Vector |
asVector()
Returns the matrix values as a single reference Vector in the form [row0
row1 row2....]
|
void |
clamp(double min,
double max)
Clamps all the elements of this array within the specified [min,max] range
|
Matrix |
copy()
Returns a defensive copy of the array data.
|
void |
copyColumnTo(int col,
double[] dest,
int destOffset)
Copies the elements in a selected row of this matrix to a double array
|
void |
copyRowTo(int row,
double[] dest,
int destOffset)
Copies the elements in a slected row of this matrix to a double array
|
static Matrix |
create(AMatrix m)
Creates a new mutable dense matrix containing a copy of another matroix
|
static Matrix |
create(AVector... data)
Creates a new Matrix using the given vectors as row data
|
static Matrix |
create(double[][] data) |
static Matrix |
create(INDArray m) |
static Matrix |
create(int... shape)
Creates a new zero-filled matrix of the specified shape.
|
static Matrix |
create(int rowCount,
int columnCount)
Creates a new zero-filled matrix of the specified shape.
|
static Matrix |
createFromRows(Object... rows) |
static Matrix |
createIdentity(int dims)
Creates a square identity Matrix of the specified size.
aij = 0 if i ≠ j aij = 1 if i = j |
static Matrix |
createIdentity(int numRows,
int numCols)
Creates a Matrix which contains ones along the main diagonal and zeros
everywhere else.
|
static Matrix |
createRandom(int rows,
int cols) |
Iterator<Double> |
elementIterator()
Returns an iterator over all elements in this array, in row-major order
|
double |
elementMax()
Returns the maximum element value in this array.
|
double |
elementMin()
Returns the maximum element value in this array.
|
double |
elementSquaredSum()
Returns the squared sum of all elements in this matrix
|
double |
elementSum()
Returns the sum of all elements in this matrix
|
Matrix |
exactClone()
Creates a deep clone of an array, using the same class implementation as the original array
|
void |
exp()
Computes the function e^x (in-place) for all array elements
|
void |
fill(double value)
Fills this array with a single double value.
|
double |
get(int i,
int j)
Returns the double value at the specified position in a 2D matrix
|
int |
getArrayOffset()
Gets the data array offset for the first element of this strided array
|
StridedVector |
getBand(int band)
Gets a specific band of the matrix, as a view vector.
|
AStridedVector |
getColumn(int col)
Returns a column of the matrix.
|
void |
getElements(double[] dest,
int offset)
Gets all elements of the array, copying them into a double array at the specified offset
|
ArraySubVector |
getRow(int row)
Returns a row of the matrix.
|
ArraySubVector |
getRowView(int row)
Returns a row of the matrix as a vector view.
|
DenseColumnMatrix |
getTranspose()
Returns the transpose of this array.
|
DenseColumnMatrix |
getTransposeView()
Returns a transposed view of the array.
|
protected int |
index(int i,
int j)
Computes the index into the underlying data array for a given position in this array-backed matrix
|
Matrix |
innerProduct(AMatrix a)
Computes the inner product of this matrix with another.
|
Vector |
innerProduct(AVector a)
Computes the inner product of this array with a vector
|
boolean |
isBoolean()
Returns true if the array is boolean (contains only 0.0 or 1.0 values)
|
boolean |
isFullyMutable()
If this method returns true, the INDArray is guaranteed to be fully mutable
in all positions i.e.
|
boolean |
isPackedArray()
Returns true if the data array is fully packed by this matrix in row-major order
|
boolean |
isView()
Return true if this array is considered as a view type.
|
boolean |
isZero()
Returns true if the matrix is the zero matrix (all components zero)
|
void |
log()
Computes the natural logarithm (in-place) for all array elements
|
void |
multiply(double factor)
Multiplies all elements of the array in place by a given double value
|
void |
multiplyRow(int i,
double factor)
Multiplies a row by a constant factor
This is an elementary row operation
|
long |
nonZeroCount()
Returns the number of non-zero elements in the array.
|
void |
reciprocal()
Replaces all elements in the array with their reciprocal
|
static void |
scale(Matrix dest,
Matrix src,
double factor) |
static void |
scaleAdd(Matrix dest,
Matrix a,
Matrix b,
double bFactor) |
void |
set(AMatrix a)
Sets this matrix with the element values from another matrix.
|
void |
set(AVector a)
Sets every row of this matrix with the element values from a vector.
|
void |
set(int i,
int j,
double value)
Sets a value at a given position in a mutable 2D array
|
void |
setColumn(int j,
AVector col)
Sets a column in a matrix.
|
void |
setMultiple(Matrix m,
double factor) |
void |
setRow(int i,
AVector row)
Sets a row in a matrix to the value specified by the given vector
|
void |
signum()
Calculates the signum of all elements of this mutable array
Sets each component of the array to its sign value (-1, 0 or 1)
|
void |
square()
Squares all elements of the array in place
|
AStridedMatrix |
subMatrix(int rowStart,
int rows,
int colStart,
int cols)
Gets a rectangular submatrix view of part of a matrix
|
void |
swapColumns(int i,
int j)
Swaps two columns of the matrix in place
|
void |
swapRows(int i,
int j)
Swaps two rows of the matrix in place
This is an elementary row operation
|
double[] |
toDoubleArray()
Copies the elements of this array to a new double[] array.
|
void |
toDoubleBuffer(DoubleBuffer dest)
Copies the elements of this INDArray to the specified double buffer
|
Matrix |
toMatrix()
Coerces the matrix to the standard mutable Matrix type
in row major order.
|
Matrix |
toMatrixTranspose()
Coerces the transpose of a matrix to the standard mutable Matrix type
in row major order.
|
Vector |
toVector()
Coerces the array into a flattened dense Vector, in row-major order
May return the same array if it is already a Vector instance
|
void |
transform(AVector source,
AVector dest)
Transforms a source vector into a destination vector, using matrix multiplication (inner product).
|
void |
transform(Vector source,
Vector dest) |
Matrix |
transposeInnerProduct(Matrix s) |
double |
unsafeGet(int i,
int j)
Gets an element in the matrix in an unsafe fashion, without performing bound checks
The result is undefined if the row and column are out of bounds.
|
void |
unsafeSet(int i,
int j,
double value)
Sets an element value in the matrix in an unsafe fashion, without performing bound checks
The result is undefined if the row and column are out of bounds.
|
static Matrix |
wrap(int rowCount,
int columnCount,
double[] data)
Wraps a double[] array as a dense Matrix.
|
add, add, addOuterProduct, addToArray, columnStride, equals, equals, equalsArray, isLowerTriangular, isUpperTriangular, reduce, rowDotProduct, rowStride, setElements, setElementsapplyOpCopy, clone, diagonalProduct, getColumnView, getStride, getStrides, tracegetArray, getTransposeCopybandLength, checkColumn, checkIndex, checkRow, checkSameShape, checkSameShape, checkSquare, columnCount, elementCount, getShape, getShape, getShapeClone, isSameShape, isSameShape, isSameShape, isSquare, rowCountadd, addCopy, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addOuterProduct, applyOp, applyOp, applyOp, applyOp, asElementList, bandIndex, bandLength, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, checkColumnCount, checkDimension, checkRowCount, checkShape, composeWith, dense, denseClone, determinant, dimensionality, divide, divide, divide, divide, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, epsilonEquals, equals, equalsByRows, equalsTranspose, get, get, get, getBandWrapped, getColumnClone, getColumns, getLeadingDiagonal, getLongShape, getRowClone, getRows, getSlices, getSlices, getSliceViews, hashCode, hasOrthonormalColumns, hasOrthonormalRows, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, inverse, isDiagonal, isElementConstrained, isHermitian, isIdentity, isInvertible, isMutable, isOrthogonal, isOrthogonal, isPositiveDefinite, isRectangularDiagonal, isSymmetric, iterator, join, lowerBandwidth, lowerBandwidthLimit, mul, multiply, multiply, multiply, multiplyCopy, mutable, negate, outerProduct, outputDimensions, pow, rank, reduce, reduceSlices, reduceSlices, reorder, reorder, replaceColumn, replaceRow, reshape, reshape, rotateView, scaleAdd, scaleAdd, set, set, set, set, set, set, setElements, slice, slice, sliceCount, sparse, sparseClone, sqrt, sub, sub, sub, subArray, toAffineTransform, toArray, toMutableMatrix, toNestedDoubleArrays, toSliceArray, toString, toStringFull, transformInPlace, transformInPlace, transposeInnerProduct, transposeInPlace, upperBandwidth, upperBandwidthLimit, validateabsCopy, add, addAt, addInnerProduct, addPower, addPower, broadcastLike, checkMutable, componentCount, density, divideCopy, elementAbsPowSum, elementPowSum, elementProduct, equals, equalsArray, get, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, isSparse, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setInnerProduct, setMultiple, setMultiple, signumCopy, sliceValue, squareCopy, sub, sub, subCopy, withComponentsfinalize, getClass, notify, notifyAll, wait, wait, waitaddCopy, addCopy, columnCount, diagonalProduct, getColumnClone, getColumns, getColumnView, getRowClone, getRows, innerProduct, inverse, isDiagonal, isIdentity, isInvertible, isRectangularDiagonal, isSquare, isSymmetric, rowCount, toNestedDoubleArrays, trace, transformInPlace, transposeInPlaceabsCopy, add, addAt, addCopy, addCopy, addInnerProduct, addMultiple, addOuterProduct, addPower, addPower, applyOp, applyOp, applyOpCopy, asElementList, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, checkMutable, clone, componentCount, dense, denseClone, dimensionality, divide, divide, divideCopy, elementAbsPowSum, elementCount, elementPowSum, elementProduct, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, equalsArray, get, get, get, get, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTransposeCopy, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, isDense, isElementConstrained, isMutable, isSameShape, isSparse, join, join, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, outerProduct, pow, reciprocalCopy, reduce, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, set, setElements, setInnerProduct, setMultiple, setMultiple, signumCopy, slice, slice, sliceCount, sliceValue, sparse, sparseClone, sqrt, squareCopy, sub, sub, subArray, subCopy, toArray, toSliceArray, validate, withComponentsgetArraygetArrayforEach, spliteratorpublic Matrix(AMatrix m)
m - public Matrix(int rowCount,
int columnCount)
public static Matrix create(int rowCount, int columnCount)
public static Matrix create(int... shape)
public static Matrix create(AMatrix m)
public static Matrix createRandom(int rows, int cols)
public static Matrix create(double[][] data)
public static Matrix create(AVector... data)
data - public boolean isFullyMutable()
INDArrayisFullyMutable in interface INDArrayisFullyMutable in class AMatrixpublic boolean isView()
INDArraypublic boolean isBoolean()
INDArraypublic boolean isZero()
AMatrixisZero in interface INDArrayisZero in class ADenseArrayMatrixpublic boolean isPackedArray()
AArrayMatrixisPackedArray in interface IStridedArrayisPackedArray in class ADenseArrayMatrixpublic static Matrix wrap(int rowCount, int columnCount, double[] data)
rowCount - columnCount - data - public AStridedMatrix subMatrix(int rowStart, int rows, int colStart, int cols)
IMatrixsubMatrix in interface IMatrixsubMatrix in class AStridedMatrixpublic Vector innerProduct(AVector a)
INDArrayinnerProduct in interface INDArrayinnerProduct in interface IMatrixinnerProduct in class AMatrixa - A vectorpublic Matrix innerProduct(AMatrix a)
IMatrixinnerProduct in interface IMatrixinnerProduct in class AMatrixpublic Matrix transposeInnerProduct(Matrix s)
transposeInnerProduct in class AMatrixpublic double elementSum()
AMatrixelementSum in interface INDArrayelementSum in class ADenseArrayMatrixpublic double elementSquaredSum()
AMatrixelementSquaredSum in interface INDArrayelementSquaredSum in class ADenseArrayMatrixpublic double elementMax()
INDArrayelementMax in interface INDArrayelementMax in class ADenseArrayMatrixpublic double elementMin()
INDArrayelementMin in interface INDArrayelementMin in class ADenseArrayMatrixpublic void abs()
INDArraypublic void signum()
INDArraypublic void square()
INDArraypublic void exp()
INDArraypublic void log()
INDArraypublic long nonZeroCount()
INDArraynonZeroCount in interface INDArraynonZeroCount in class AMatrixpublic final void copyRowTo(int row,
double[] dest,
int destOffset)
AMatrixcopyRowTo in class ADenseArrayMatrixrow - The index of the selected rowdest - Destination double[] arraydestOffset - Offset into destination arraypublic final void copyColumnTo(int col,
double[] dest,
int destOffset)
AMatrixcopyColumnTo in class AStridedMatrixdest - Destination double[] arraypublic void transform(AVector source, AVector dest)
IMatrixtransform in interface IMatrixtransform in class ADenseArrayMatrixpublic ArraySubVector getRow(int row)
IMatrixpublic ArraySubVector getRowView(int row)
IMatrixgetRowView in interface IMatrixgetRowView in class AStridedMatrixpublic AStridedVector getColumn(int col)
IMatrixgetColumn in interface IMatrixgetColumn in class ADenseArrayMatrixpublic void swapRows(int i,
int j)
AMatrixpublic void swapColumns(int i,
int j)
AMatrixswapColumns in class AMatrixpublic void multiplyRow(int i,
double factor)
AMatrixmultiplyRow in class AMatrixpublic void addRowMultiple(int src,
int dst,
double factor)
AMatrixaddRowMultiple in class AMatrixpublic Vector asVector()
AMatrixasVector in interface INDArrayasVector in class ADenseArrayMatrixpublic Vector toVector()
INDArraypublic final Matrix toMatrix()
AMatrixpublic final double[] toDoubleArray()
INDArraytoDoubleArray in interface INDArraytoDoubleArray in class AMatrixpublic Matrix toMatrixTranspose()
AMatrixtoMatrixTranspose in class AMatrixpublic void toDoubleBuffer(DoubleBuffer dest)
INDArraytoDoubleBuffer in interface INDArraytoDoubleBuffer in class AMatrixpublic double[] asDoubleArray()
INDArrayasDoubleArray in interface INDArrayasDoubleArray in class AStridedMatrixpublic double get(int i,
int j)
INDArraypublic void unsafeSet(int i,
int j,
double value)
AMatrixunsafeSet in class ADenseArrayMatrixpublic double unsafeGet(int i,
int j)
AMatrixunsafeGet in class ADenseArrayMatrixpublic void addAt(int i,
int j,
double d)
IMatrixpublic void set(int i,
int j,
double value)
INDArraypublic void applyOp(Op op)
INDArrayapplyOp in interface INDArrayapplyOp in class AStridedMatrixpublic void applyOp(Op2 op, double b)
INDArraypublic void addMultiple(ADenseArrayMatrix m, double factor)
public void setMultiple(Matrix m, double factor)
public void add(AMatrix m)
AMatrixadd in class ADenseArrayMatrixpublic void add2(AMatrix a, AMatrix b)
IMatrixpublic void addMultiple(AMatrix m, double factor)
AMatrixaddMultiple in class AMatrixpublic void add(double d)
INDArraypublic void multiply(double factor)
INDArraypublic void set(AMatrix a)
AMatrixset in class ADenseArrayMatrixpublic void set(AVector a)
AMatrixset in class ADenseArrayMatrixpublic void getElements(double[] dest,
int offset)
INDArraygetElements in interface INDArraygetElements in class AMatrixpublic Iterator<Double> elementIterator()
INDArrayelementIterator in interface INDArrayelementIterator in class AStridedMatrixpublic DenseColumnMatrix getTranspose()
INDArraygetTranspose in interface INDArraygetTranspose in interface IMatrixgetTranspose in class AStridedMatrixpublic DenseColumnMatrix getTransposeView()
INDArraygetTransposeView in interface INDArraygetTransposeView in interface IMatrixgetTransposeView in class AStridedMatrixpublic void fill(double value)
INDArraypublic void reciprocal()
INDArrayreciprocal in interface INDArrayreciprocal in class AMatrixpublic void clamp(double min,
double max)
INDArraypublic Matrix copy()
INDArraypublic Matrix exactClone()
INDArrayexactClone in interface INDArrayexactClone in class AMatrixpublic void setRow(int i,
AVector row)
AMatrixsetRow in class ADenseArrayMatrixpublic void setColumn(int j,
AVector col)
AMatrixpublic StridedVector getBand(int band)
AMatrixgetBand in interface IMatrixgetBand in class AStridedMatrixprotected final int index(int i,
int j)
AArrayMatrixindex in class ADenseArrayMatrixpublic int getArrayOffset()
IStridedArraygetArrayOffset in interface IDenseArraygetArrayOffset in interface IStridedArraygetArrayOffset in class ADenseArrayMatrixpublic static Matrix createIdentity(int numRows, int numCols)
numRows - Number of rows in the matrix.numCols - NUmber of columns in the matrix.public static Matrix createIdentity(int dims)
Creates a square identity Matrix of the specified size.
aij = 0 if i ≠ j
aij = 1 if i = j
Copyright © 2016. All rights reserved.