Package org.la4j.matrix.dense
Class Basic1DMatrix
- java.lang.Object
-
- org.la4j.Matrix
-
- org.la4j.matrix.DenseMatrix
-
- org.la4j.matrix.dense.Basic1DMatrix
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Double>
public class Basic1DMatrix extends DenseMatrix
-
-
Field Summary
Fields Modifier and Type Field Description private static byteMATRIX_TAGprivate double[]self
-
Constructor Summary
Constructors Constructor Description Basic1DMatrix()Basic1DMatrix(int rows, int columns)Basic1DMatrix(int rows, int columns, double[] array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixblankOfShape(int rows, int columns)Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rowsxcolumns.static Basic1DMatrixblock(Matrix a, Matrix b, Matrix c, Matrix d)static Basic1DMatrixconstant(int rows, int columns, double constant)Creates a constantBasic1DMatrixof the given shape andvalue.MatrixcopyOfShape(int rows, int columns)Copies this matrix into the new matrix with specified dimensions:rowsandcolumns.static Basic1DMatrixdiagonal(int size, double diagonal)static Basic1DMatrixfrom1DArray(int rows, int columns, double[] array)Creates aBasic1DMatrixof the given 1Darrayw/o copying the underlying array.static Basic1DMatrixfrom2DArray(double[][] array)Creates aBasic1DMatrixof the given 2Darraywith copying the underlying array.static Basic1DMatrixfromBinary(byte[] array)DecodesBasic1DMatrixfrom the given bytearray.static Basic1DMatrixfromCSV(java.lang.String csv)ParsesBasic1DMatrixfrom the given CSV string.static Basic1DMatrixfromMatrixMarket(java.lang.String mm)ParsesBasic1DMatrixfrom the given Matrix Market string.doubleget(int i, int j)Gets the specified element of this matrix.VectorgetRow(int i)Copies the specified row of this matrix into the vector.static Basic1DMatrixidentity(int size)Creates an identityBasic1DMatrixof the givensize.static Basic1DMatrixrandom(int rows, int columns, java.util.Random random)static Basic1DMatrixrandomSymmetric(int size, java.util.Random random)Creates a random symmetricBasic1DMatrixof the givensize.voidset(int i, int j, double value)Sets the specified element of this matrix to givenvalue.voidsetAll(double value)Sets all elements of this matrix to the givenvalue.voidswapColumns(int i, int j)Swaps the specified columns of this matrix.voidswapRows(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 Basic1DMatrixunit(int rows, int columns)static Basic1DMatrixzero(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
-
-
-
-
Field Detail
-
MATRIX_TAG
private static final byte MATRIX_TAG
- See Also:
- Constant Field Values
-
self
private double[] self
-
-
Method Detail
-
zero
public static Basic1DMatrix zero(int rows, int columns)
-
constant
public static Basic1DMatrix constant(int rows, int columns, double constant)
Creates a constantBasic1DMatrixof the given shape andvalue.
-
diagonal
public static Basic1DMatrix diagonal(int size, double diagonal)
-
unit
public static Basic1DMatrix unit(int rows, int columns)
-
identity
public static Basic1DMatrix identity(int size)
Creates an identityBasic1DMatrixof the givensize.
-
random
public static Basic1DMatrix random(int rows, int columns, java.util.Random random)
-
randomSymmetric
public static Basic1DMatrix randomSymmetric(int size, java.util.Random random)
Creates a random symmetricBasic1DMatrixof the givensize.
-
from1DArray
public static Basic1DMatrix from1DArray(int rows, int columns, double[] array)
Creates aBasic1DMatrixof the given 1Darrayw/o copying the underlying array.
-
from2DArray
public static Basic1DMatrix from2DArray(double[][] array)
Creates aBasic1DMatrixof the given 2Darraywith copying the underlying array.
-
block
public static Basic1DMatrix block(Matrix a, Matrix b, Matrix c, Matrix d)
-
fromBinary
public static Basic1DMatrix fromBinary(byte[] array)
DecodesBasic1DMatrixfrom the given bytearray.- Parameters:
array- the byte array representing a matrix- Returns:
- a decoded matrix
-
fromCSV
public static Basic1DMatrix fromCSV(java.lang.String csv)
ParsesBasic1DMatrixfrom the given CSV string.- Parameters:
csv- the CSV string representing a matrix- Returns:
- a parsed matrix
-
fromMatrixMarket
public static Basic1DMatrix fromMatrixMarket(java.lang.String mm)
ParsesBasic1DMatrixfrom 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:MatrixGets the specified element of this matrix.
-
set
public void set(int i, int j, double value)Description copied from class:MatrixSets the specified element of this matrix to givenvalue.
-
setAll
public void setAll(double value)
Description copied from class:MatrixSets all elements of this matrix to the givenvalue.
-
swapRows
public void swapRows(int i, int j)Description copied from class:MatrixSwaps the specified rows of this matrix.
-
swapColumns
public void swapColumns(int i, int j)Description copied from class:MatrixSwaps the specified columns of this matrix.- Overrides:
swapColumnsin classMatrix- Parameters:
i- the column indexj- the column index
-
getRow
public Vector getRow(int i)
Description copied from class:MatrixCopies the specified row of this matrix into the vector.- Overrides:
getRowin classDenseMatrix- Parameters:
i- the row index- Returns:
- the row represented as vector
-
copyOfShape
public Matrix copyOfShape(int rows, int columns)
Description copied from class:MatrixCopies this matrix into the new matrix with specified dimensions:rowsandcolumns.- Specified by:
copyOfShapein 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:DenseMatrixConverts this dense matrix to double array.- Specified by:
toArrayin classDenseMatrix- Returns:
- an array representation of this matrix
-
to
public <T extends Matrix> T to(MatrixFactory<T> factory)
Description copied from class:MatrixConverts this matrix using the givenfactory.
-
blankOfShape
public Matrix blankOfShape(int rows, int columns)
Description copied from class:MatrixCreates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rowsxcolumns.- Specified by:
blankOfShapein classMatrix- Returns:
- blank matrix
-
-