org.la4j.matrix.dense

## Class Basic2DMatrix

• All Implemented Interfaces:
Iterable<Double>

```public class Basic2DMatrix
extends DenseMatrix```

• ### Fields inherited from class org.la4j.Matrix

`columns, rows`
• ### Constructor Summary

Constructors
Constructor and Description
`Basic2DMatrix()`
`Basic2DMatrix(double[][] array)`
```Basic2DMatrix(int rows, int columns)```
• ### Method Summary

Methods
Modifier and Type Method and Description
`Matrix` ```blankOfShape(int rows, int columns)```
Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape: `rows` x `columns`.
`static Basic2DMatrix` ```block(Matrix a, Matrix b, Matrix c, Matrix d)```
Creates a block `Basic2DMatrix` of the given blocks `a`, `b`, `c` and `d`.
`static Basic2DMatrix` ```constant(int rows, int columns, double constant)```
Creates a constant `Basic2DMatrix` of the given shape and `value`.
`Matrix` ```copyOfShape(int rows, int columns)```
Copies this matrix into the new matrix with specified dimensions: `rows` and `columns`.
`static Basic2DMatrix` ```diagonal(int size, double diagonal)```
Creates a diagonal `Basic2DMatrix` of the given `size` whose diagonal elements are equal to `diagonal`.
`static Basic2DMatrix` ```from1DArray(int rows, int columns, double[] array)```
Creates a `Basic2DMatrix` of the given 1D `array` with copying the underlying array.
`static Basic2DMatrix` `from2DArray(double[][] array)`
Creates a `Basic2DMatrix` of the given 2D `array` w/o copying the underlying array.
`static Basic2DMatrix` `fromBinary(byte[] array)`
Decodes `Basic2DMatrix` from the given byte `array`.
`static Basic2DMatrix` `fromCSV(String csv)`
Parses `Basic2DMatrix` from the given CSV string.
`static Basic2DMatrix` `fromMatrixMarket(String mm)`
Parses `Basic2DMatrix` from the given Matrix Market string.
`double` ```get(int i, int j)```
Gets the specified element of this matrix.
`Vector` `getRow(int i)`
Copies the specified row of this matrix into the vector.
`static Basic2DMatrix` `identity(int size)`
Creates an identity `Basic2DMatrix` of the given `size`.
`static Basic2DMatrix` ```random(int rows, int columns, Random random)```
Creates a random `Basic2DMatrix` of the given shape: `rows` x `columns`.
`static Basic2DMatrix` ```randomSymmetric(int size, Random random)```
Creates a random symmetric `Basic2DMatrix` of the given `size`.
`void` ```set(int i, int j, double value)```
Sets the specified element of this matrix to given `value`.
`void` `setAll(double value)`
Sets all elements of this matrix to the given `value`.
`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> T` `to(MatrixFactory<T> factory)`
Converts this matrix using the given `factory`.
`double[][]` `toArray()`
Converts this dense matrix to double array.
`byte[]` `toBinary()`
Encodes this matrix into a byte array.
`static Basic2DMatrix` ```unit(int rows, int columns)```
Creates an unit `Basic2DMatrix` of the given shape: `rows` x `columns`.
`static Basic2DMatrix` ```zero(int rows, int columns)```
Creates a zero `Basic2DMatrix` of the given shape: `rows` x `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`
• ### Constructor Detail

• #### Basic2DMatrix

`public Basic2DMatrix()`
• #### Basic2DMatrix

```public Basic2DMatrix(int rows,
int columns)```
• #### Basic2DMatrix

`public Basic2DMatrix(double[][] array)`
• ### Method Detail

• #### zero

```public static Basic2DMatrix zero(int rows,
int columns)```
Creates a zero `Basic2DMatrix` of the given shape: `rows` x `columns`.
• #### constant

```public static Basic2DMatrix constant(int rows,
int columns,
double constant)```
Creates a constant `Basic2DMatrix` of the given shape and `value`.
• #### diagonal

```public static Basic2DMatrix diagonal(int size,
double diagonal)```
Creates a diagonal `Basic2DMatrix` of the given `size` whose diagonal elements are equal to `diagonal`.
• #### unit

```public static Basic2DMatrix unit(int rows,
int columns)```
Creates an unit `Basic2DMatrix` of the given shape: `rows` x `columns`.
• #### identity

`public static Basic2DMatrix identity(int size)`
Creates an identity `Basic2DMatrix` of the given `size`.
• #### random

```public static Basic2DMatrix random(int rows,
int columns,
Random random)```
Creates a random `Basic2DMatrix` of the given shape: `rows` x `columns`.
• #### randomSymmetric

```public static Basic2DMatrix randomSymmetric(int size,
Random random)```
Creates a random symmetric `Basic2DMatrix` of the given `size`.
• #### from1DArray

```public static Basic2DMatrix from1DArray(int rows,
int columns,
double[] array)```
Creates a `Basic2DMatrix` of the given 1D `array` with copying the underlying array.
• #### from2DArray

`public static Basic2DMatrix from2DArray(double[][] array)`
Creates a `Basic2DMatrix` of the given 2D `array` w/o copying the underlying array.
• #### block

```public static Basic2DMatrix block(Matrix a,
Matrix b,
Matrix c,
Matrix d)```
Creates a block `Basic2DMatrix` of the given blocks `a`, `b`, `c` and `d`.
• #### fromBinary

`public static Basic2DMatrix fromBinary(byte[] array)`
Decodes `Basic2DMatrix` from the given byte `array`.
Parameters:
`array` - the byte array representing a matrix
Returns:
a decoded matrix
• #### fromCSV

`public static Basic2DMatrix fromCSV(String csv)`
Parses `Basic2DMatrix` from the given CSV string.
Parameters:
`csv` - the CSV string representing a matrix
Returns:
a parsed matrix
• #### fromMatrixMarket

`public static Basic2DMatrix fromMatrixMarket(String mm)`
Parses `Basic2DMatrix` 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.
Specified by:
`get` in class `Matrix`
Parameters:
`i` - element's row index
`j` - element's column index
Returns:
the 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 given `value`.
Specified by:
`set` in class `Matrix`
Parameters:
`i` - element's row index
`j` - element's column index
`value` - element's new value
• #### setAll

`public void setAll(double value)`
Description copied from class: `Matrix`
Sets all elements of this matrix to the given `value`.
Overrides:
`setAll` in class `Matrix`
Parameters:
`value` - the element's new value
• #### swapRows

```public void swapRows(int i,
int j)```
Description copied from class: `Matrix`
Swaps the specified rows of this matrix.
Overrides:
`swapRows` in class `Matrix`
Parameters:
`i` - the row index
`j` - the row index
• #### swapColumns

```public void swapColumns(int i,
int j)```
Description copied from class: `Matrix`
Swaps the specified columns of this matrix.
Overrides:
`swapColumns` in class `Matrix`
Parameters:
`i` - the column index
`j` - the column index
• #### getRow

`public Vector getRow(int i)`
Description copied from class: `Matrix`
Copies the specified row of this matrix into the vector.
Overrides:
`getRow` in class `DenseMatrix`
Parameters:
`i` - the row index
Returns:
the row represented as vector
• #### copyOfShape

```public Matrix copyOfShape(int rows,
int columns)```
Description copied from class: `Matrix`
Copies this matrix into the new matrix with specified dimensions: `rows` and `columns`.
Specified by:
`copyOfShape` in class `Matrix`
Parameters:
`rows` - the number of rows in new matrix
`columns` - 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 class `DenseMatrix`
Returns:
an array representation of this matrix
• #### to

`public <T extends Matrix> T to(MatrixFactory<T> factory)`
Description copied from class: `Matrix`
Converts this matrix using the given `factory`.
Overrides:
`to` in class `Matrix`
Type Parameters:
`T` - type of the result matrix
Parameters:
`factory` - the factory that creates an output matrix
Returns:
converted matrix
• #### blankOfShape

```public Matrix blankOfShape(int rows,
int columns)```
Description copied from class: `Matrix`
Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape: `rows` x `columns`.
Specified by:
`blankOfShape` in class `Matrix`
Returns:
blank matrix
• #### toBinary

`public byte[] toBinary()`
Description copied from class: `Matrix`
Encodes this matrix into a byte array.
Specified by:
`toBinary` in class `Matrix`
Returns:
a byte array representing this matrix