Package org.jblas
Class ComplexDoubleMatrix
java.lang.Object
org.jblas.ComplexDoubleMatrix
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ComplexDoubleMatrix of size 0 times 0.ComplexDoubleMatrix
(double[] newData) ComplexDoubleMatrix
(double[][] data) Creates a new n times m ComplexDoubleMatrix from the given n times m 2D data array.ComplexDoubleMatrix
(int len) Create a Matrix of length len.ComplexDoubleMatrix
(int newRows, int newColumns) Creates a new n times m ComplexDoubleMatrix.ComplexDoubleMatrix
(int newRows, int newColumns, double... newData) Create a new matrix with newRows rows, newColumns columns using newData as the data.ComplexDoubleMatrix
(String filename) Creates a new matrix by reading it from a file.ComplexDoubleMatrix
(ComplexDouble[] newData) Construct a complex matrix from a real matrix.ComplexDoubleMatrix
(DoubleMatrix real, DoubleMatrix imag) Construct a complex matrix from separate real and imaginary parts. -
Method Summary
Modifier and TypeMethodDescriptionadd
(double v) add
(ComplexDouble v) add
(ComplexDoubleMatrix other) void
Add a vector to all columns of the matrixaddi
(double v) addi
(double v, ComplexDoubleMatrix result) addi
(ComplexDoubleMatrix other) Code for operatorsaddi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) Add two matrices.addi
(ComplexDouble v, ComplexDoubleMatrix result) Add a scalar to a matrix.void
Add a row vector to all rows of the matrixand
(double value) and
(ComplexDouble value) and
(ComplexDoubleMatrix other) andi
(double value) andi
(double value, ComplexDoubleMatrix result) andi
(ComplexDouble value) andi
(ComplexDoubleMatrix other) andi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) andi
(ComplexDouble value, ComplexDoubleMatrix 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 ComplexDoubleMatrix
static ComplexDoubleMatrix
conj()
Compute complex conjugate.conji()
Compute complex conjugate (in-place).Copy ComplexDoubleMatrix a to this.diag()
Get diagonal of the matrix.static ComplexDoubleMatrix
Creates a new matrix where the values of the given vector are the diagonal values of the matrix.static ComplexDoubleMatrix
diag
(ComplexDoubleMatrix x, int rows, int columns) Construct a matrix of arbitrary shape and set the diagonal according to a passed vector.div
(double v) div
(ComplexDouble v) div
(ComplexDoubleMatrix other) divi
(double v) divi
(double a, ComplexDoubleMatrix result) divi
(ComplexDoubleMatrix other) divi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) (Elementwise) divisiondivi
(ComplexDouble a, ComplexDoubleMatrix result) (Elementwise) division with a scalardotc
(ComplexDoubleMatrix other) Computes this^T * otherdotu
(ComplexDoubleMatrix other) Computes this^H * otherdup()
Returns a duplicate of this matrix.eq
(double value) eq
(ComplexDouble value) eq
(ComplexDoubleMatrix other) eqi
(double value) eqi
(double value, ComplexDoubleMatrix result) eqi
(ComplexDouble value) eqi
(ComplexDoubleMatrix other) eqi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) eqi
(ComplexDouble value, ComplexDoubleMatrix 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, ComplexDouble result) Get matrix element, passing the variable to store the result.get
(int i, ComplexDouble result) get
(int r, ComplexDoubleMatrix indices) get
(ComplexDoubleMatrix indices) get
(ComplexDoubleMatrix indices, int c) get
(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices) getColumn
(int c) int
double
getImag
(int i) int
getReal()
double
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
(double v) mmul
(ComplexDoubleMatrix other) mmuli
(double v) mmuli
(double v, ComplexDoubleMatrix result) mmuli
(ComplexDoubleMatrix other) mmuli
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) Matrix-Matrix Multiplicationmmuli
(ComplexDouble v, ComplexDoubleMatrix result) Matrix-Matrix Multiplication with a scalar (for symmetry, does the same as muli(scalar)mul
(double v) mul
(ComplexDouble v) mul
(ComplexDoubleMatrix other) muli
(double v) muli
(double v, ComplexDoubleMatrix result) muli
(ComplexDoubleMatrix other) muli
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) (Elementwise) Multiplicationmuli
(ComplexDouble v, ComplexDoubleMatrix result) (Elementwise) Multiplication with a scalarboolean
Check whether this can be multiplied with a.ne
(double value) ne
(ComplexDouble value) ne
(ComplexDoubleMatrix other) neg()
negi()
nei
(double value) nei
(double value, ComplexDoubleMatrix result) nei
(ComplexDouble value) nei
(ComplexDoubleMatrix other) nei
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) nei
(ComplexDouble value, ComplexDoubleMatrix result) double
norm1()
double
norm2()
double
normmax()
not()
noti()
static ComplexDoubleMatrix
ones
(int length) static ComplexDoubleMatrix
ones
(int rows, int columns) Creates a new matrix in which all values are equal 1.or
(double value) or
(ComplexDouble value) or
(ComplexDoubleMatrix other) ori
(double value) ori
(double value, ComplexDoubleMatrix result) ori
(ComplexDouble value) ori
(ComplexDoubleMatrix other) ori
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) ori
(ComplexDouble value, ComplexDoubleMatrix 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, double v) put
(int[] rindices, int[] cindices, double v) put
(int[] rindices, int[] cindices, ComplexDouble v) put
(int[] rindices, int[] cindices, ComplexDoubleMatrix x) put
(int[] indices, int c, double v) put
(int[] indices, int c, ComplexDouble v) put
(int[] indices, int c, ComplexDoubleMatrix x) put
(int[] indices, ComplexDouble v) put
(int[] indices, ComplexDoubleMatrix x) put
(int i, double v) put
(int i, double r, double c) put
(int r, int[] indices, double v) put
(int r, int[] indices, ComplexDouble v) put
(int r, int[] indices, ComplexDoubleMatrix x) put
(int rowIndex, int columnIndex, double value) Set matrix elementput
(int rowIndex, int columnIndex, double realValue, double complexValue) put
(int rowIndex, int columnIndex, ComplexDouble value) put
(int i, ComplexDouble v) put
(int r, ComplexDoubleMatrix indices, double v) put
(int r, ComplexDoubleMatrix indices, ComplexDouble v) put
(int r, ComplexDoubleMatrix indices, ComplexDoubleMatrix v) put
(ComplexDoubleMatrix indices, double v) put
(ComplexDoubleMatrix indices, int c, double v) put
(ComplexDoubleMatrix indices, int c, ComplexDouble v) put
(ComplexDoubleMatrix indices, int c, ComplexDoubleMatrix v) put
(ComplexDoubleMatrix indices, ComplexDouble v) put
(ComplexDoubleMatrix indices, ComplexDoubleMatrix v) put
(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, double v) put
(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, ComplexDouble v) put
(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, ComplexDoubleMatrix v) void
putColumn
(int c, ComplexDoubleMatrix v) putImag
(int[] indices, double v) putImag
(int[] rindices, int[] cindices, double v) putImag
(int[] indices, int c, double v) putImag
(int i, double v) putImag
(int r, int[] indices, double v) putImag
(int rowIndex, int columnIndex, double value) putImag
(int r, ComplexDoubleMatrix indices, double v) putImag
(ComplexDoubleMatrix indices, double v) putImag
(ComplexDoubleMatrix indices, int c, double v) putImag
(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, double v) putReal
(int[] indices, double v) putReal
(int[] rindices, int[] cindices, double v) putReal
(int[] indices, int c, double v) putReal
(int i, double v) putReal
(int r, int[] indices, double v) putReal
(int rowIndex, int columnIndex, double value) putReal
(int r, ComplexDoubleMatrix indices, double v) putReal
(ComplexDoubleMatrix indices, double v) putReal
(ComplexDoubleMatrix indices, int c, double v) putReal
(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, double v) void
putRow
(int r, ComplexDoubleMatrix v) rankOneUpdate
(double alpha, ComplexDoubleMatrix x) Computes a rank-1-update A = A + alpha * x * x'.rankOneUpdate
(double alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y) Computes a rank-1-update A = A + x * x'.Computes a rank-1-update A = A + x * y'.rankOneUpdate
(ComplexDouble alpha, ComplexDoubleMatrix x) Computes a rank-1-update A = A + alpha * x * x'.rankOneUpdate
(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y) Computes a rank-1-update A = A + alpha * x * y'.rdiv
(double v) rdiv
(ComplexDoubleMatrix other) rdivi
(double v) rdivi
(double a, ComplexDoubleMatrix result) rdivi
(ComplexDoubleMatrix other) rdivi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) (Elementwise) division, with operands switched.rdivi
(ComplexDouble a, ComplexDoubleMatrix 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
(double v) rsub
(ComplexDoubleMatrix other) rsubi
(double v) rsubi
(double a, ComplexDoubleMatrix result) rsubi
(ComplexDoubleMatrix other) rsubi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) Subtract two matrices, but subtract first from second matrix, that is, compute result = other - this.rsubi
(ComplexDouble a, ComplexDoubleMatrix 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 ComplexDoubleMatrix
scalar
(double s) Create a 1 * 1 - matrix.sub
(double v) sub
(ComplexDouble v) sub
(ComplexDoubleMatrix other) void
Add a vector to all columns of the matrixsubi
(double v) subi
(double v, ComplexDoubleMatrix result) subi
(ComplexDoubleMatrix other) subi
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) Subtract two matrices.subi
(ComplexDouble v, ComplexDoubleMatrix 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()
ComplexDouble[][]
toArray2()
boolean[]
boolean[][]
double[]
toString()
Generate string representation of this matrix (multi-line).Return transposed copy of this matrixtruth()
truthi()
xor
(double value) xor
(ComplexDouble value) xor
(ComplexDoubleMatrix other) xori
(double value) xori
(double value, ComplexDoubleMatrix result) xori
(ComplexDouble value) xori
(ComplexDoubleMatrix other) xori
(ComplexDoubleMatrix other, ComplexDoubleMatrix result) xori
(ComplexDouble value, ComplexDoubleMatrix result) static ComplexDoubleMatrix
zeros
(int length) static ComplexDoubleMatrix
zeros
(int rows, int columns) Creates a new matrix in which all values are equal 0.
-
Field Details
-
rows
-
columns
-
length
-
data
-
-
Constructor Details
-
ComplexDoubleMatrix
Create a new matrix with newRows rows, newColumns columns using newData as the data. -
ComplexDoubleMatrix
Creates a new n times m ComplexDoubleMatrix.- Parameters:
newRows
- the number of rows (n) of the new matrix.newColumns
- the number of columns (m) of the new matrix.
-
ComplexDoubleMatrix
public ComplexDoubleMatrix()Creates a new ComplexDoubleMatrix of size 0 times 0. -
ComplexDoubleMatrix
Create a Matrix of length len. By default, this creates a row vector.- Parameters:
len
-
-
ComplexDoubleMatrix
-
ComplexDoubleMatrix
-
ComplexDoubleMatrix
Construct a complex matrix from a real matrix. -
ComplexDoubleMatrix
Construct a complex matrix from separate real and imaginary parts. Either part can be set to null in which case it will be ignored. -
ComplexDoubleMatrix
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
-
ComplexDoubleMatrix
Creates a new n times m ComplexDoubleMatrix 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 ComplexDoubleMatrix(new double[][]{{1d, 2d, 3d}, {4d, 5d, 6d}, {7d, 8d, 9d}}).print();
will constructs the following matrix:1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
.- 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 double- Parameters:
s
- value of the matrix- Returns:
- the constructed ComplexDoubleMatrix
-
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 ComplexDoubleMatrix put(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, ComplexDoubleMatrix v) -
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
-
putReal
-
putImag
-
put
-
put
public ComplexDoubleMatrix put(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, double v) -
putReal
public ComplexDoubleMatrix putReal(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, double v) -
putImag
public ComplexDoubleMatrix putImag(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, double v) -
put
public ComplexDoubleMatrix put(ComplexDoubleMatrix rindices, ComplexDoubleMatrix cindices, ComplexDouble 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 ComplexDoubleMatrix 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
public ComplexDoubleMatrix put(int rowIndex, int columnIndex, double realValue, double complexValue) -
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 ComplexDoubleMatrix rankOneUpdate(ComplexDouble alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y) Computes a rank-1-update A = A + alpha * x * y'. -
rankOneUpdate
public ComplexDoubleMatrix rankOneUpdate(double alpha, ComplexDoubleMatrix x, ComplexDoubleMatrix y) -
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
-