Class ComplexFloatMatrix
java.lang.Object
org.jblas.ComplexFloatMatrix
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ComplexFloatMatrix of size 0 times 0.ComplexFloatMatrix(float[] newData) ComplexFloatMatrix(float[][] data) Creates a new n times m ComplexFloatMatrix from the given n times m 2D data array.ComplexFloatMatrix(int len) Create a Matrix of length len.ComplexFloatMatrix(int newRows, int newColumns) Creates a new n times m ComplexFloatMatrix.ComplexFloatMatrix(int newRows, int newColumns, float... newData) Create a new matrix with newRows rows, newColumns columns using newData as the data.ComplexFloatMatrix(String filename) Creates a new matrix by reading it from a file.ComplexFloatMatrix(ComplexFloat[] newData) Construct a complex matrix from a real matrix.ComplexFloatMatrix(FloatMatrix real, FloatMatrix imag) Construct a complex matrix from separate real and imaginary parts. -
Method Summary
Modifier and TypeMethodDescriptionadd(float v) add(ComplexFloat v) add(ComplexFloatMatrix other) voidAdd a vector to all columns of the matrixaddi(float v) addi(float v, ComplexFloatMatrix result) addi(ComplexFloat v) addi(ComplexFloatMatrix other) Code for operatorsaddi(ComplexFloatMatrix other, ComplexFloatMatrix result) Add two matrices.addi(ComplexFloat v, ComplexFloatMatrix result) Add a scalar to a matrix.voidAdd a row vector to all rows of the matrixand(float value) and(ComplexFloat value) and(ComplexFloatMatrix other) andi(float value) andi(float value, ComplexFloatMatrix result) andi(ComplexFloat value) andi(ComplexFloatMatrix other) andi(ComplexFloatMatrix other, ComplexFloatMatrix result) andi(ComplexFloat value, ComplexFloatMatrix result) voidvoidvoidAssert that two matrices have the same size.voidprivate voidcheckColumns(int c) private voidcheckLength(int l) private voidcheckRows(int r) Return a vector containing the sums of the columns (having number of columns many entries)static ComplexFloatMatrixstatic ComplexFloatMatrixconj()Compute complex conjugate.conji()Compute complex conjugate (in-place).Copy ComplexFloatMatrix a to this.diag()Get diagonal of the matrix.static ComplexFloatMatrixCreates a new matrix where the values of the given vector are the diagonal values of the matrix.static ComplexFloatMatrixdiag(ComplexFloatMatrix x, int rows, int columns) Construct a matrix of arbitrary shape and set the diagonal according to a passed vector.div(float v) div(ComplexFloat v) div(ComplexFloatMatrix other) divi(float v) divi(float a, ComplexFloatMatrix result) divi(ComplexFloat v) divi(ComplexFloatMatrix other) divi(ComplexFloatMatrix other, ComplexFloatMatrix result) (Elementwise) divisiondivi(ComplexFloat a, ComplexFloatMatrix result) (Elementwise) division with a scalardotc(ComplexFloatMatrix other) Computes this^T * otherdotu(ComplexFloatMatrix other) Computes this^H * otherdup()Returns a duplicate of this matrix.private voidensureResultLength(ComplexFloatMatrix other, ComplexFloatMatrix result) Ensures that the result vector has the same length as this.eq(float value) eq(ComplexFloat value) eq(ComplexFloatMatrix other) eqi(float value) eqi(float value, ComplexFloatMatrix result) eqi(ComplexFloat value) eqi(ComplexFloatMatrix other) eqi(ComplexFloatMatrix other, ComplexFloatMatrix result) eqi(ComplexFloat value, ComplexFloatMatrix result) booleanCompare two matrices.int[]get(int i) get(int[] indices) Working with slices (Man! 30+ methods just to make this a bit flexible...)get(int[] indices, int c) get(int[] rindices, int[] cindices) get(int rowIndex, int columnIndex) Retrieve matrix elementget(int r, int[] indices) get(int rowIndex, int columnIndex, ComplexFloat result) Get matrix element, passing the variable to store the result.get(int i, ComplexFloat result) get(int r, ComplexFloatMatrix indices) get(ComplexFloatMatrix indices) get(ComplexFloatMatrix indices, int c) get(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices) getColumn(int c) intfloatgetImag(int i) intgetReal()floatgetReal(int i) getRow(int r) intgetRows()inthashCode()imag()Get imaginary part of the matrix.voidin(DataInputStream dis) Reads in a matrix from the given data stream.intindex(int rowIndex, int columnIndex) Get index of an elementintindexColumns(int i) Compute the column index of a linear index.intindexRows(int i) Compute the row index of a linear index.booleanbooleanisEmpty()Checks whether the matrix is empty.booleanbooleanisScalar()Test whether a matrix is scalarbooleanisSquare()Checks whether the matrix is square.booleanisVector()Checks whether the matrix is a vector.voidLoads a matrix from a file into this matrix.mean()mmul(float v) mmul(ComplexFloat v) mmul(ComplexFloatMatrix other) mmuli(float v) mmuli(float v, ComplexFloatMatrix result) mmuli(ComplexFloatMatrix other) mmuli(ComplexFloatMatrix other, ComplexFloatMatrix result) Matrix-Matrix Multiplicationmmuli(ComplexFloat v, ComplexFloatMatrix result) Matrix-Matrix Multiplication with a scalar (for symmetry, does the same as muli(scalar)mul(float v) mul(ComplexFloat v) mul(ComplexFloatMatrix other) muli(float v) muli(float v, ComplexFloatMatrix result) muli(ComplexFloat v) muli(ComplexFloatMatrix other) muli(ComplexFloatMatrix other, ComplexFloatMatrix result) (Elementwise) Multiplicationmuli(ComplexFloat v, ComplexFloatMatrix result) (Elementwise) Multiplication with a scalarbooleanCheck whether this can be multiplied with a.ne(float value) ne(ComplexFloat value) ne(ComplexFloatMatrix other) neg()negi()nei(float value) nei(float value, ComplexFloatMatrix result) nei(ComplexFloat value) nei(ComplexFloatMatrix other) nei(ComplexFloatMatrix other, ComplexFloatMatrix result) nei(ComplexFloat value, ComplexFloatMatrix result) floatnorm1()floatnorm2()floatnormmax()not()noti()static ComplexFloatMatrixones(int length) static ComplexFloatMatrixones(int rows, int columns) Creates a new matrix in which all values are equal 1.or(float value) or(ComplexFloat value) or(ComplexFloatMatrix other) ori(float value) ori(float value, ComplexFloatMatrix result) ori(ComplexFloat value) ori(ComplexFloatMatrix other) ori(ComplexFloatMatrix other, ComplexFloatMatrix result) ori(ComplexFloat value, ComplexFloatMatrix result) voidout(DataOutputStream dos) Writes out this matrix to the given data stream.voidprint()Pretty-print this matrix to System.out.put(int[] indices, float v) put(int[] rindices, int[] cindices, float v) put(int[] rindices, int[] cindices, ComplexFloat v) put(int[] rindices, int[] cindices, ComplexFloatMatrix x) put(int[] indices, int c, float v) put(int[] indices, int c, ComplexFloat v) put(int[] indices, int c, ComplexFloatMatrix x) put(int[] indices, ComplexFloat v) put(int[] indices, ComplexFloatMatrix x) put(int i, float v) put(int i, float r, float c) put(int r, int[] indices, float v) put(int r, int[] indices, ComplexFloat v) put(int r, int[] indices, ComplexFloatMatrix x) put(int rowIndex, int columnIndex, float value) Set matrix elementput(int rowIndex, int columnIndex, float realValue, float complexValue) put(int rowIndex, int columnIndex, ComplexFloat value) put(int i, ComplexFloat v) put(int r, ComplexFloatMatrix indices, float v) put(int r, ComplexFloatMatrix indices, ComplexFloat v) put(int r, ComplexFloatMatrix indices, ComplexFloatMatrix v) put(ComplexFloatMatrix indices, float v) put(ComplexFloatMatrix indices, int c, float v) put(ComplexFloatMatrix indices, int c, ComplexFloat v) put(ComplexFloatMatrix indices, int c, ComplexFloatMatrix v) put(ComplexFloatMatrix indices, ComplexFloat v) put(ComplexFloatMatrix indices, ComplexFloatMatrix v) put(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, float v) put(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, ComplexFloat v) put(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, ComplexFloatMatrix v) voidputColumn(int c, ComplexFloatMatrix v) putImag(int[] indices, float v) putImag(int[] rindices, int[] cindices, float v) putImag(int[] indices, int c, float v) putImag(int i, float v) putImag(int r, int[] indices, float v) putImag(int rowIndex, int columnIndex, float value) putImag(int r, ComplexFloatMatrix indices, float v) putImag(ComplexFloatMatrix indices, float v) putImag(ComplexFloatMatrix indices, int c, float v) putImag(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, float v) putReal(int[] indices, float v) putReal(int[] rindices, int[] cindices, float v) putReal(int[] indices, int c, float v) putReal(int i, float v) putReal(int r, int[] indices, float v) putReal(int rowIndex, int columnIndex, float value) putReal(int r, ComplexFloatMatrix indices, float v) putReal(ComplexFloatMatrix indices, float v) putReal(ComplexFloatMatrix indices, int c, float v) putReal(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, float v) voidputRow(int r, ComplexFloatMatrix v) rankOneUpdate(float alpha, ComplexFloatMatrix x) Computes a rank-1-update A = A + alpha * x * x'.rankOneUpdate(float alpha, ComplexFloatMatrix x, ComplexFloatMatrix y) Computes a rank-1-update A = A + x * x'.Computes a rank-1-update A = A + x * y'.rankOneUpdate(ComplexFloat alpha, ComplexFloatMatrix x) Computes a rank-1-update A = A + alpha * x * x'.rankOneUpdate(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y) Computes a rank-1-update A = A + alpha * x * y'.rdiv(float v) rdiv(ComplexFloat v) rdiv(ComplexFloatMatrix other) rdivi(float v) rdivi(float a, ComplexFloatMatrix result) rdivi(ComplexFloatMatrix other) rdivi(ComplexFloatMatrix other, ComplexFloatMatrix result) (Elementwise) division, with operands switched.rdivi(ComplexFloat a, ComplexFloatMatrix result) (Elementwise) division with a scalar, with operands switched.real()Get real part of the matrix.reshape(int newRows, int newColumns) Reshape the matrix.voidresize(int newRows, int newColumns) Resize the matrix.rowMeans()rowSums()rsub(float v) rsub(ComplexFloat v) rsub(ComplexFloatMatrix other) rsubi(float v) rsubi(float a, ComplexFloatMatrix result) rsubi(ComplexFloatMatrix other) rsubi(ComplexFloatMatrix other, ComplexFloatMatrix result) Subtract two matrices, but subtract first from second matrix, that is, compute result = other - this.rsubi(ComplexFloat a, ComplexFloatMatrix result) Subtract a matrix from a scalarbooleanbooleanChecks whether two matrices have the same size.voidSaves this matrix to the specified file.scalar()Return the first element of the matrixstatic ComplexFloatMatrixscalar(float s) Create a 1 * 1 - matrix.sub(float v) sub(ComplexFloat v) sub(ComplexFloatMatrix other) voidAdd a vector to all columns of the matrixsubi(float v) subi(float v, ComplexFloatMatrix result) subi(ComplexFloat v) subi(ComplexFloatMatrix other) subi(ComplexFloatMatrix other, ComplexFloatMatrix result) Subtract two matrices.subi(ComplexFloat v, ComplexFloatMatrix result) Subtract a scalar from a matrixvoidAdd a row vector to all rows of the matrixsum()Logical operationsswapColumns(int i, int j) swapRows(int i, int j) toArray()ComplexFloat[][]toArray2()boolean[]boolean[][]float[]toString()Generate string representation of this matrix (multi-line).Return transposed copy of this matrixtruth()truthi()xor(float value) xor(ComplexFloat value) xor(ComplexFloatMatrix other) xori(float value) xori(float value, ComplexFloatMatrix result) xori(ComplexFloat value) xori(ComplexFloatMatrix other) xori(ComplexFloatMatrix other, ComplexFloatMatrix result) xori(ComplexFloat value, ComplexFloatMatrix result) static ComplexFloatMatrixzeros(int length) static ComplexFloatMatrixzeros(int rows, int columns) Creates a new matrix in which all values are equal 0.
-
Field Details
-
rows
public int rows -
columns
public int columns -
length
public int length -
data
public float[] data
-
-
Constructor Details
-
ComplexFloatMatrix
public ComplexFloatMatrix(int newRows, int newColumns, float... newData) Create a new matrix with newRows rows, newColumns columns using newData as the data. -
ComplexFloatMatrix
public ComplexFloatMatrix(int newRows, int newColumns) Creates a new n times m ComplexFloatMatrix.- Parameters:
newRows- the number of rows (n) of the new matrix.newColumns- the number of columns (m) of the new matrix.
-
ComplexFloatMatrix
public ComplexFloatMatrix()Creates a new ComplexFloatMatrix of size 0 times 0. -
ComplexFloatMatrix
public ComplexFloatMatrix(int len) Create a Matrix of length len. By default, this creates a row vector.- Parameters:
len-
-
ComplexFloatMatrix
public ComplexFloatMatrix(float[] newData) -
ComplexFloatMatrix
-
ComplexFloatMatrix
Construct a complex matrix from a real matrix. -
ComplexFloatMatrix
Construct a complex matrix from separate real and imaginary parts. Either part can be set to null in which case it will be ignored. -
ComplexFloatMatrix
Creates a new matrix by reading it from a file.- Parameters:
filename- the path and name of the file to read the matrix from- Throws:
IOException
-
ComplexFloatMatrix
public ComplexFloatMatrix(float[][] data) Creates a new n times m ComplexFloatMatrix from the given n times m 2D data array. The first dimension of the array makes the rows (n) and the second dimension the columns (m). For example, the given code
new ComplexFloatMatrix(new float[][]{{1d, 2d, 3d}, {4d, 5d, 6d}, {7d, 8d, 9d}}).print();
will constructs the following matrix:1.0f 2.0f 3.0f 4.0f 5.0f 6.0f 7.0f 8.0f 9.0f
.- Parameters:
data- n times m data array
-
-
Method Details
-
zeros
Creates a new matrix in which all values are equal 0.- Parameters:
rows- number of rowscolumns- number of columns- Returns:
- new matrix
-
zeros
-
ones
Creates a new matrix in which all values are equal 1.- Parameters:
rows- number of rowscolumns- number of columns- Returns:
- new matrix
-
ones
-
diag
Creates a new matrix where the values of the given vector are the diagonal values of the matrix.- Parameters:
x- the diagonal values- Returns:
- new matrix
-
diag
Construct a matrix of arbitrary shape and set the diagonal according to a passed vector. length of needs to be smaller than rows or columns.- Parameters:
x- vector to fill the diagonal withrows- number of rows of the resulting matrixcolumns- number of columns of the resulting matrix- Returns:
- a matrix with dimensions rows * columns whose diagonal elements are filled by x
-
scalar
Create a 1 * 1 - matrix. For many operations, this matrix functions like a normal float- Parameters:
s- value of the matrix- Returns:
- the constructed ComplexFloatMatrix
-
isScalar
public boolean isScalar()Test whether a matrix is scalar -
scalar
Return the first element of the matrix -
concatHorizontally
-
concatVertically
-
get
Working with slices (Man! 30+ methods just to make this a bit flexible...) -
get
-
get
-
get
-
get
-
get
-
get
-
get
-
checkLength
private void checkLength(int l) -
checkRows
private void checkRows(int r) -
checkColumns
private void checkColumns(int c) -
put
-
put
-
put
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
put
-
put
-
put
public ComplexFloatMatrix put(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, ComplexFloatMatrix v) -
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
putReal
public ComplexFloatMatrix putReal(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, float v) -
putImag
public ComplexFloatMatrix putImag(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, float v) -
put
public ComplexFloatMatrix put(ComplexFloatMatrix rindices, ComplexFloatMatrix cindices, ComplexFloat v) -
findIndices
public int[] findIndices() -
transpose
Return transposed copy of this matrix -
hermitian
-
conji
Compute complex conjugate (in-place). -
conj
Compute complex conjugate. -
equals
-
hashCode
-
resize
public void resize(int newRows, int newColumns) Resize the matrix. All elements will be set to zero. -
reshape
Reshape the matrix. Number of elements must not change. -
sameSize
Checks whether two matrices have the same size. -
assertSameSize
Assert that two matrices have the same size.- Parameters:
a- the other matrix- Throws:
SizeException- if matrix sizes don't match.
-
multipliesWith
Check whether this can be multiplied with a.- Parameters:
a- right-hand-side of the multiplication.- Returns:
- true iff this.columns == a.rows
-
assertMultipliesWith
-
sameLength
-
assertSameLength
-
copy
Copy ComplexFloatMatrix a to this. this a is resized if necessary. -
dup
Returns a duplicate of this matrix. Geometry is the same (including offsets, transpose, etc.), but the buffer is not shared. -
swapColumns
-
swapRows
-
put
Set matrix element -
put
-
put
-
putReal
-
putImag
-
get
Retrieve matrix element -
get
Get matrix element, passing the variable to store the result. -
getReal
-
index
public int index(int rowIndex, int columnIndex) Get index of an element -
indexRows
public int indexRows(int i) Compute the row index of a linear index. -
indexColumns
public int indexColumns(int i) Compute the column index of a linear index. -
get
-
get
-
getReal
public float getReal(int i) -
getImag
public float getImag(int i) -
put
-
put
-
put
-
putReal
-
putImag
-
getRows
public int getRows() -
getColumns
public int getColumns() -
getLength
public int getLength() -
isEmpty
public boolean isEmpty()Checks whether the matrix is empty. -
isSquare
public boolean isSquare()Checks whether the matrix is square. -
assertSquare
public void assertSquare() -
isVector
public boolean isVector()Checks whether the matrix is a vector. -
isRowVector
public boolean isRowVector() -
isColumnVector
public boolean isColumnVector() -
diag
Get diagonal of the matrix. -
real
Get real part of the matrix. -
imag
Get imaginary part of the matrix. -
print
public void print()Pretty-print this matrix to System.out. -
toString
-
toDoubleArray
public float[] toDoubleArray() -
toArray
-
toArray2
-
toBooleanArray
public boolean[] toBooleanArray() -
toBooleanArray2
public boolean[][] toBooleanArray2() -
ensureResultLength
Ensures that the result vector has the same length as this. If not, resizing result is tried, which fails if result == this or result == other. -
addi
Add two matrices. -
addi
Add a scalar to a matrix. -
addi
-
subi
Subtract two matrices. -
subi
Subtract a scalar from a matrix -
subi
-
rsubi
Subtract two matrices, but subtract first from second matrix, that is, compute result = other - this. -
rsubi
Subtract a matrix from a scalar -
rsubi
-
muli
(Elementwise) Multiplication -
muli
(Elementwise) Multiplication with a scalar -
muli
-
mmuli
Matrix-Matrix Multiplication -
mmuli
Matrix-Matrix Multiplication with a scalar (for symmetry, does the same as muli(scalar) -
mmuli
-
divi
(Elementwise) division -
divi
(Elementwise) division with a scalar -
divi
-
rdivi
(Elementwise) division, with operands switched. Computes result = other / this. -
rdivi
(Elementwise) division with a scalar, with operands switched. Computes result = a / this. -
rdivi
-
negi
-
neg
-
noti
-
not
-
truthi
-
truth
-
rankOneUpdate
public ComplexFloatMatrix rankOneUpdate(ComplexFloat alpha, ComplexFloatMatrix x, ComplexFloatMatrix y) Computes a rank-1-update A = A + alpha * x * y'. -
rankOneUpdate
-
rankOneUpdate
Computes a rank-1-update A = A + alpha * x * x'. -
rankOneUpdate
Computes a rank-1-update A = A + alpha * x * x'. -
rankOneUpdate
Computes a rank-1-update A = A + x * x'. -
rankOneUpdate
Computes a rank-1-update A = A + x * y'. -
sum
Logical operations -
mean
-
dotc
Computes this^T * other -
dotu
Computes this^H * other -
norm2
public float norm2() -
normmax
public float normmax() -
norm1
public float norm1() -
columnSums
Return a vector containing the sums of the columns (having number of columns many entries) -
columnMeans
-
rowSums
-
rowMeans
-
getColumn
-
putColumn
-
getRow
-
putRow
-
addRowVector
Add a row vector to all rows of the matrix -
addColumnVector
Add a vector to all columns of the matrix -
subRowVector
Add a row vector to all rows of the matrix -
subColumnVector
Add a vector to all columns of the matrix -
out
Writes out this matrix to the given data stream.- Parameters:
dos- the data output stream to write to.- Throws:
IOException
-
in
Reads in a matrix from the given data stream. Note that the old data of this matrix will be discarded.- Parameters:
dis- the data input stream to read from.- Throws:
IOException
-
save
Saves this matrix to the specified file.- Parameters:
filename- the file to write the matrix in.- Throws:
IOException- thrown on errors while writing the matrix to the file
-
load
Loads a matrix from a file into this matrix. Note that the old data of this matrix will be discarded.- Parameters:
filename- the file to read the matrix from- Throws:
IOException- thrown on errors while reading the matrix
-
addi
Code for operators -
add
-
addi
-
addi
-
add
-
add
-
subi
-
sub
-
subi
-
subi
-
sub
-
sub
-
rsubi
-
rsub
-
rsubi
-
rsubi
-
rsub
-
rsub
-
divi
-
div
-
divi
-
divi
-
div
-
div
-
rdivi
-
rdiv
-
rdivi
-
rdivi
-
rdiv
-
rdiv
-
muli
-
mul
-
muli
-
muli
-
mul
-
mul
-
mmuli
-
mmul
-
mmuli
-
mmuli
-
mmul
-
mmul
-
eqi
-
eqi
-
eq
-
eqi
-
eqi
-
eqi
-
eqi
-
eq
-
eq
-
nei
-
nei
-
ne
-
nei
-
nei
-
nei
-
nei
-
ne
-
ne
-
andi
-
andi
-
and
-
andi
-
andi
-
andi
-
andi
-
and
-
and
-
ori
-
ori
-
or
-
ori
-
ori
-
ori
-
ori
-
or
-
or
-
xori
-
xori
-
xor
-
xori
-
xori
-
xori
-
xori
-
xor
-
xor
-