Package org.jblas
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) void
Add 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.void
Add 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) void
void
void
Assert that two matrices have the same size.void
Return a vector containing the sums of the columns (having number of columns many entries)static ComplexFloatMatrix
static ComplexFloatMatrix
conj()
Compute complex conjugate.conji()
Compute complex conjugate (in-place).Copy ComplexFloatMatrix a to this.diag()
Get diagonal of the matrix.static ComplexFloatMatrix
Creates a new matrix where the values of the given vector are the diagonal values of the matrix.static ComplexFloatMatrix
diag
(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.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) boolean
Compare 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) int
float
getImag
(int i) int
getReal()
float
getReal
(int i) getRow
(int r) int
getRows()
int
hashCode()
imag()
Get imaginary part of the matrix.void
in
(DataInputStream dis) Reads in a matrix from the given data stream.int
index
(int rowIndex, int columnIndex) Get index of an elementint
indexColumns
(int i) Compute the column index of a linear index.int
indexRows
(int i) Compute the row index of a linear index.boolean
boolean
isEmpty()
Checks whether the matrix is empty.boolean
boolean
isScalar()
Test whether a matrix is scalarboolean
isSquare()
Checks whether the matrix is square.boolean
isVector()
Checks whether the matrix is a vector.void
Loads 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 scalarboolean
Check 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) float
norm1()
float
norm2()
float
normmax()
not()
noti()
static ComplexFloatMatrix
ones
(int length) static ComplexFloatMatrix
ones
(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) void
out
(DataOutputStream dos) Writes out this matrix to the given data stream.void
print()
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) void
putColumn
(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) void
putRow
(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.void
resize
(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 scalarboolean
boolean
Checks whether two matrices have the same size.void
Saves this matrix to the specified file.scalar()
Return the first element of the matrixstatic ComplexFloatMatrix
scalar
(float s) Create a 1 * 1 - matrix.sub
(float v) sub
(ComplexFloat v) sub
(ComplexFloatMatrix other) void
Add 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 matrixvoid
Add 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 ComplexFloatMatrix
zeros
(int length) static ComplexFloatMatrix
zeros
(int rows, int columns) Creates a new matrix in which all values are equal 0.
-
Field Details
-
rows
-
columns
-
length
-
data
-
-
Constructor Details
-
ComplexFloatMatrix
Create a new matrix with newRows rows, newColumns columns using newData as the data. -
ComplexFloatMatrix
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
Create a Matrix of length len. By default, this creates a row vector.- Parameters:
len
-
-
ComplexFloatMatrix
-
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
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
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
-
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
-
transpose
Return transposed copy of this matrix -
hermitian
-
conji
Compute complex conjugate (in-place). -
conj
Compute complex conjugate. -
equals
Compare two matrices. -
hashCode
-
resize
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
Get index of an element -
indexRows
Compute the row index of a linear index. -
indexColumns
Compute the column index of a linear index. -
get
-
get
-
getReal
-
getImag
-
put
-
put
-
put
-
putReal
-
putImag
-
getRows
-
getColumns
-
getLength
-
isEmpty
Checks whether the matrix is empty. -
isSquare
Checks whether the matrix is square. -
assertSquare
-
isVector
Checks whether the matrix is a vector. -
isRowVector
-
isColumnVector
-
diag
Get diagonal of the matrix. -
real
Get real part of the matrix. -
imag
Get imaginary part of the matrix. -
print
Pretty-print this matrix to System.out. -
toString
Generate string representation of this matrix (multi-line). -
toDoubleArray
-
toArray
-
toArray2
-
toBooleanArray
-
toBooleanArray2
-
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
-
normmax
-
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
-