Package org.la4j.matrix.dense
Class Basic1DMatrix
java.lang.Object
org.la4j.Matrix
org.la4j.matrix.DenseMatrix
org.la4j.matrix.dense.Basic1DMatrix
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBasic1DMatrix
(int rows, int columns) Basic1DMatrix
(int rows, int columns, double[] array) -
Method Summary
Modifier and TypeMethodDescriptionblankOfShape
(int rows, int columns) Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rows
xcolumns
.static Basic1DMatrix
static Basic1DMatrix
constant
(int rows, int columns, double constant) Creates a constantBasic1DMatrix
of the given shape andvalue
.copyOfShape
(int rows, int columns) Copies this matrix into the new matrix with specified dimensions:rows
andcolumns
.static Basic1DMatrix
diagonal
(int size, double diagonal) static Basic1DMatrix
from1DArray
(int rows, int columns, double[] array) Creates aBasic1DMatrix
of the given 1Darray
w/o copying the underlying array.static Basic1DMatrix
from2DArray
(double[][] array) Creates aBasic1DMatrix
of the given 2Darray
with copying the underlying array.static Basic1DMatrix
fromBinary
(byte[] array) DecodesBasic1DMatrix
from the given bytearray
.static Basic1DMatrix
ParsesBasic1DMatrix
from the given CSV string.static Basic1DMatrix
ParsesBasic1DMatrix
from the given Matrix Market string.double
get
(int i, int j) Gets the specified element of this matrix.getRow
(int i) Copies the specified row of this matrix into the vector.static Basic1DMatrix
identity
(int size) Creates an identityBasic1DMatrix
of the givensize
.static Basic1DMatrix
static Basic1DMatrix
randomSymmetric
(int size, Random random) Creates a random symmetricBasic1DMatrix
of the givensize
.void
set
(int i, int j, double value) Sets the specified element of this matrix to givenvalue
.void
setAll
(double value) Sets all elements of this matrix to the givenvalue
.void
swapColumns
(int i, int j) Swaps the specified columns of this matrix.void
swapRows
(int i, int j) Swaps the specified rows of this matrix.<T extends Matrix>
Tto
(MatrixFactory<T> factory) Converts this matrix using the givenfactory
.double[][]
toArray()
Converts this dense matrix to double array.byte[]
toBinary()
Encodes this matrix into a byte array.static Basic1DMatrix
unit
(int rows, int columns) static Basic1DMatrix
zero
(int rows, int columns) Methods inherited from class org.la4j.matrix.DenseMatrix
apply, apply, apply, getColumn, toMatrixMarket
Methods inherited from class org.la4j.Matrix
add, add, blank, blankOfColumns, blankOfRows, columnMajorIterator, columns, copy, copyOfColumns, copyOfRows, determinant, diagonalProduct, divide, each, eachInColumn, eachInRow, ensureDimensionsAreCorrect, ensureIndexesAreInBounds, equals, equals, euclideanNorm, fail, fold, foldColumn, foldColumns, foldRow, foldRows, hadamardProduct, hashCode, infinityNorm, insert, insert, insert, insert, insertColumn, insertRow, is, is, iterator, iteratorOfColumn, iteratorOfRow, kroneckerProduct, manhattanNorm, max, maxInColumn, maxInRow, min, minInColumn, minInRow, mkString, mkString, mkString, multiply, multiply, multiply, multiplyByItsTranspose, non, non, norm, power, product, rank, removeColumn, removeFirstColumn, removeFirstRow, removeLastColumn, removeLastRow, removeRow, rotate, rowMajorIterator, rows, select, setColumn, setColumn, setRow, setRow, shuffle, slice, sliceBottomRight, sliceTopLeft, subtract, subtract, sum, toColumnMajorSparseMatrix, toColumnVector, toCSV, toCSV, toDenseMatrix, toMatrixMarket, toRowMajorSparseMatrix, toRowVector, toSparseMatrix, toString, trace, transform, transformColumn, transformRow, transpose, update, updateAt, updateColumn, updateRow, withDecompositor, withInverter, withSolver
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MATRIX_TAG
private static final byte MATRIX_TAG- See Also:
-
self
private double[] self
-
-
Constructor Details
-
Basic1DMatrix
public Basic1DMatrix() -
Basic1DMatrix
public Basic1DMatrix(int rows, int columns) -
Basic1DMatrix
public Basic1DMatrix(int rows, int columns, double[] array)
-
-
Method Details
-
zero
-
constant
Creates a constantBasic1DMatrix
of the given shape andvalue
. -
diagonal
-
unit
-
identity
Creates an identityBasic1DMatrix
of the givensize
. -
random
-
randomSymmetric
Creates a random symmetricBasic1DMatrix
of the givensize
. -
from1DArray
Creates aBasic1DMatrix
of the given 1Darray
w/o copying the underlying array. -
from2DArray
Creates aBasic1DMatrix
of the given 2Darray
with copying the underlying array. -
block
-
fromBinary
DecodesBasic1DMatrix
from the given bytearray
.- Parameters:
array
- the byte array representing a matrix- Returns:
- a decoded matrix
-
fromCSV
ParsesBasic1DMatrix
from the given CSV string.- Parameters:
csv
- the CSV string representing a matrix- Returns:
- a parsed matrix
-
fromMatrixMarket
ParsesBasic1DMatrix
from the given Matrix Market string.- Parameters:
mm
- the string in Matrix Market format- Returns:
- a parsed matrix
-
get
public double get(int i, int j) Description copied from class:Matrix
Gets the specified element of this matrix. -
set
public void set(int i, int j, double value) Description copied from class:Matrix
Sets the specified element of this matrix to givenvalue
. -
setAll
public void setAll(double value) Description copied from class:Matrix
Sets all elements of this matrix to the givenvalue
. -
swapRows
public void swapRows(int i, int j) Description copied from class:Matrix
Swaps the specified rows of this matrix. -
swapColumns
public void swapColumns(int i, int j) Description copied from class:Matrix
Swaps the specified columns of this matrix.- Overrides:
swapColumns
in classMatrix
- Parameters:
i
- the column indexj
- the column index
-
getRow
Description copied from class:Matrix
Copies the specified row of this matrix into the vector.- Overrides:
getRow
in classDenseMatrix
- Parameters:
i
- the row index- Returns:
- the row represented as vector
-
copyOfShape
Description copied from class:Matrix
Copies this matrix into the new matrix with specified dimensions:rows
andcolumns
.- Specified by:
copyOfShape
in classMatrix
- Parameters:
rows
- the number of rows in new matrixcolumns
- the number of columns in new matrix- Returns:
- the copy of this matrix with new size
-
toArray
public double[][] toArray()Description copied from class:DenseMatrix
Converts this dense matrix to double array.- Specified by:
toArray
in classDenseMatrix
- Returns:
- an array representation of this matrix
-
to
Description copied from class:Matrix
Converts this matrix using the givenfactory
. -
blankOfShape
Description copied from class:Matrix
Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rows
xcolumns
.- Specified by:
blankOfShape
in classMatrix
- Returns:
- blank matrix
-
toBinary
public byte[] toBinary()Description copied from class:Matrix
Encodes this matrix into a byte array.
-