Class DenseDComplexMatrix1D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.AbstractMatrix
-
- cern.colt.matrix.AbstractMatrix1D
-
- cern.colt.matrix.tdcomplex.DComplexMatrix1D
-
- cern.colt.matrix.tdcomplex.impl.DenseDComplexMatrix1D
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class DenseDComplexMatrix1D extends DComplexMatrix1D
Dense 1-d matrix (aka vector) holding complex elements.Internally holds one single contiguous one-dimensional array. Complex data is represented by 2 double values in sequence, i.e. elements[zero + 2 * k * stride] constitute real part and elements[zero + 2 * k * stride + 1] constitute imaginary part (k=0,...,size()-1).
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DenseDComplexMatrix1D(double[] values)Constructs a matrix with a copy of the given values.DenseDComplexMatrix1D(DoubleMatrix1D realPart)Constructs a complex matrix with the same size as realPart matrix and fills the real part of this matrix with elements of realPart.DenseDComplexMatrix1D(int size)Constructs a matrix with a given number of cells.DenseDComplexMatrix1D(int size, double[] elements, int zero, int stride, boolean isNoView)Constructs a matrix with the given parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[]aggregate(DComplexDComplexDComplexFunction aggr, DComplexDComplexFunction f)Applies a function to each cell and aggregates the results.double[]aggregate(DComplexMatrix1D other, DComplexDComplexDComplexFunction aggr, DComplexDComplexDComplexFunction f)Applies a function to each corresponding cell of two matrices and aggregates the results.DComplexMatrix1Dassign(DComplexDComplexFunction function)Assigns the result of a function to each cell;DComplexMatrix1Dassign(DComplexMatrix1D source)Replaces all cell values of the receiver with the values of another matrix.DComplexMatrix1Dassign(DComplexMatrix1D y, DComplexDComplexDComplexFunction function)Assigns the result of a function to each cell;DComplexMatrix1Dassign(DComplexProcedure cond, DComplexDComplexFunction function)Assigns the result of a function to all cells that satisfy a condition.DComplexMatrix1Dassign(DComplexProcedure cond, double[] value)Assigns a value to all cells that satisfy a condition.DComplexMatrix1Dassign(DComplexRealFunction function)Assigns the result of a function to the real part of the receiver.DComplexMatrix1Dassign(double[] values)Sets all cells to the state specified by values.DComplexMatrix1Dassign(double re, double im)Sets all cells to the state specified by re and im.DComplexMatrix1DassignImaginary(DoubleMatrix1D other)Replaces imaginary part of the receiver with the values of another real matrix.DComplexMatrix1DassignReal(DoubleMatrix1D other)Replaces real part of the receiver with the values of another real matrix.double[]elements()Returns the elements of this matrix.voidfft()Computes the discrete Fourier transform (DFT) of this matrix.DoubleMatrix1DgetImaginaryPart()Returns the imaginary part of this matrixvoidgetNonZeros(IntArrayList indexList, java.util.ArrayList<double[]> valueList)Fills the coordinates and values of cells having non-zero values into the specified lists.double[]getQuick(int index)Returns the matrix cell value at coordinate index.DoubleMatrix1DgetRealPart()Returns the real part of this matrixvoidifft(boolean scale)Computes the inverse of the discrete Fourier transform (IDFT) of this matrix.longindex(int rank)Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array.DComplexMatrix1Dlike(int size)Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size.DComplexMatrix2Dlike2D(int rows, int columns)Construct and returns a new 2-d matrix of the corresponding dynamic type, entirely independent of the receiver.DComplexMatrix2Dreshape(int rows, int columns)Returns new DoubleMatrix2D of size rows x columns whose elements are taken column-wise from this matrix.DComplexMatrix3Dreshape(int slices, int rows, int columns)Returns new DoubleMatrix3D of size slices x rows x columns, whose elements are taken column-wise from this matrix.voidsetQuick(int index, double[] value)Sets the matrix cell at coordinate index to the specified value.voidsetQuick(int index, double re, double im)Sets the matrix cell at coordinate index to the specified value.voidswap(DComplexMatrix1D other)Swaps each element this[i] with other[i].voidtoArray(double[] values)Fills the cell values into the specified 1-dimensional array.double[]zDotProduct(DComplexMatrix1D y, int from, int length)Returns the dot product of two vectors x and y.double[]zSum()Returns the sum of all cells.-
Methods inherited from class cern.colt.matrix.tdcomplex.DComplexMatrix1D
cardinality, copy, equals, equals, get, like, set, set, toArray, toString, toString, viewFlip, viewPart, viewSelection, viewSelection, viewStrides, zDotProduct, zDotProduct
-
Methods inherited from class cern.colt.matrix.AbstractMatrix1D
checkSize, size, stride, toStringShort
-
Methods inherited from class cern.colt.matrix.AbstractMatrix
ensureCapacity, isView, trimToSize
-
Methods inherited from class cern.colt.PersistentObject
clone
-
-
-
-
Constructor Detail
-
DenseDComplexMatrix1D
public DenseDComplexMatrix1D(double[] values)
Constructs a matrix with a copy of the given values. The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa. Due to the fact that complex data is represented by 2 double values in sequence: the real and imaginary parts, the size of new matrix will be equal to values.length / 2.- Parameters:
values- The values to be filled into the new matrix.
-
DenseDComplexMatrix1D
public DenseDComplexMatrix1D(DoubleMatrix1D realPart)
Constructs a complex matrix with the same size as realPart matrix and fills the real part of this matrix with elements of realPart.- Parameters:
realPart- a real matrix whose elements become a real part of this matrix- Throws:
java.lang.IllegalArgumentException- if size<0.
-
DenseDComplexMatrix1D
public DenseDComplexMatrix1D(int size)
Constructs a matrix with a given number of cells. All entries are initially 0.- Parameters:
size- the number of cells the matrix shall have.- Throws:
java.lang.IllegalArgumentException- if size<0.
-
DenseDComplexMatrix1D
public DenseDComplexMatrix1D(int size, double[] elements, int zero, int stride, boolean isNoView)Constructs a matrix with the given parameters.- Parameters:
size- the number of cells the matrix shall have.elements- the cells.zero- the index of the first element.stride- the number of indexes between any two elements, i.e. index(i+1)-index(i).isNoView- if false then the view is constructed- Throws:
java.lang.IllegalArgumentException- if size<0.
-
-
Method Detail
-
aggregate
public double[] aggregate(DComplexDComplexDComplexFunction aggr, DComplexDComplexFunction f)
Description copied from class:DComplexMatrix1DApplies a function to each cell and aggregates the results.- Overrides:
aggregatein classDComplexMatrix1D- Parameters:
aggr- an aggregation function taking as first argument the current aggregation and as second argument the transformed current cell value.f- a function transforming the current cell value.- Returns:
- the aggregated measure.
- See Also:
DComplexFunctions
-
aggregate
public double[] aggregate(DComplexMatrix1D other, DComplexDComplexDComplexFunction aggr, DComplexDComplexDComplexFunction f)
Description copied from class:DComplexMatrix1DApplies a function to each corresponding cell of two matrices and aggregates the results.- Overrides:
aggregatein classDComplexMatrix1D- Parameters:
other- the secondary matrix to operate on.aggr- an aggregation function taking as first argument the current aggregation and as second argument the transformed current cell values.f- a function transforming the current cell values.- Returns:
- the aggregated measure.
- See Also:
DComplexFunctions
-
assign
public DComplexMatrix1D assign(DComplexDComplexFunction function)
Description copied from class:DComplexMatrix1DAssigns the result of a function to each cell;- Overrides:
assignin classDComplexMatrix1D- Parameters:
function- a function object taking as argument the current cell's value.- Returns:
- this (for convenience only).
- See Also:
DComplexFunctions
-
assign
public DComplexMatrix1D assign(DComplexProcedure cond, DComplexDComplexFunction function)
Description copied from class:DComplexMatrix1DAssigns the result of a function to all cells that satisfy a condition.- Overrides:
assignin classDComplexMatrix1D- Parameters:
cond- a condition.function- a function object.- Returns:
- this (for convenience only).
- See Also:
DComplexFunctions
-
assign
public DComplexMatrix1D assign(DComplexProcedure cond, double[] value)
Description copied from class:DComplexMatrix1DAssigns a value to all cells that satisfy a condition.- Overrides:
assignin classDComplexMatrix1D- Parameters:
cond- a condition.value- a value (re=value[0], im=value[1]).- Returns:
- this (for convenience only).
-
assign
public DComplexMatrix1D assign(DComplexRealFunction function)
Description copied from class:DComplexMatrix1DAssigns the result of a function to the real part of the receiver. The imaginary part of the receiver is reset to zero.- Overrides:
assignin classDComplexMatrix1D- Parameters:
function- a function object taking as argument the current cell's value.- Returns:
- this (for convenience only).
- See Also:
DComplexFunctions
-
assign
public DComplexMatrix1D assign(DComplexMatrix1D source)
Description copied from class:DComplexMatrix1DReplaces all cell values of the receiver with the values of another matrix. Both matrices must have the same size. If both matrices share the same cells (as is the case if they are views derived from the same matrix) and intersect in an ambiguous way, then replaces as if using an intermediate auxiliary deep copy of other.- Overrides:
assignin classDComplexMatrix1D- Parameters:
source- the source matrix to copy from (may be identical to the receiver).- Returns:
- this (for convenience only).
-
assign
public DComplexMatrix1D assign(DComplexMatrix1D y, DComplexDComplexDComplexFunction function)
Description copied from class:DComplexMatrix1DAssigns the result of a function to each cell;- Overrides:
assignin classDComplexMatrix1D- Parameters:
y- the secondary matrix to operate on.function- a function object taking as first argument the current cell's value of this, and as second argument the current cell's value of y,- Returns:
- this (for convenience only).
- See Also:
DComplexFunctions
-
assign
public DComplexMatrix1D assign(double re, double im)
Description copied from class:DComplexMatrix1DSets all cells to the state specified by re and im.- Overrides:
assignin classDComplexMatrix1D- Parameters:
re- the real part of the value to be filled into the cells.im- the imaginary part of the value to be filled into the cells.- Returns:
- this (for convenience only).
-
assign
public DComplexMatrix1D assign(double[] values)
Description copied from class:DComplexMatrix1DSets all cells to the state specified by values. values is required to have the same number of cells as the receiver. Complex data is represented by 2 double values in sequence: the real and imaginary parts, i.e. input array must be of size 2*size().The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
- Overrides:
assignin classDComplexMatrix1D- Parameters:
values- the values to be filled into the cells.- Returns:
- this (for convenience only).
-
assignImaginary
public DComplexMatrix1D assignImaginary(DoubleMatrix1D other)
Description copied from class:DComplexMatrix1DReplaces imaginary part of the receiver with the values of another real matrix. The real part remains unchanged. Both matrices must have the same size.- Overrides:
assignImaginaryin classDComplexMatrix1D- Parameters:
other- the source matrix to copy from- Returns:
- this (for convenience only).
-
assignReal
public DComplexMatrix1D assignReal(DoubleMatrix1D other)
Description copied from class:DComplexMatrix1DReplaces real part of the receiver with the values of another real matrix. The imaginary part remains unchanged. Both matrices must have the same size.- Overrides:
assignRealin classDComplexMatrix1D- Parameters:
other- the source matrix to copy from- Returns:
- this (for convenience only).
-
fft
public void fft()
Computes the discrete Fourier transform (DFT) of this matrix. Throws IllegalArgumentException if the size of this matrix is not a power of 2 number.
-
elements
public double[] elements()
Description copied from class:DComplexMatrix1DReturns the elements of this matrix.- Specified by:
elementsin classDComplexMatrix1D- Returns:
- the elements
-
getImaginaryPart
public DoubleMatrix1D getImaginaryPart()
Description copied from class:DComplexMatrix1DReturns the imaginary part of this matrix- Specified by:
getImaginaryPartin classDComplexMatrix1D- Returns:
- the imaginary part
-
getNonZeros
public void getNonZeros(IntArrayList indexList, java.util.ArrayList<double[]> valueList)
Description copied from class:DComplexMatrix1DFills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values.In general, fill order is unspecified. This implementation fills like: for (index = 0..size()-1) do ... . However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell).
- Overrides:
getNonZerosin classDComplexMatrix1D- Parameters:
indexList- the list to be filled with indexes, can have any size.valueList- the list to be filled with values, can have any size.
-
getQuick
public double[] getQuick(int index)
Description copied from class:DComplexMatrix1DReturns the matrix cell value at coordinate index.Provided with invalid parameters this method may return invalid objects without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): index<0 || index>=size().
- Specified by:
getQuickin classDComplexMatrix1D- Parameters:
index- the index of the cell.- Returns:
- the value of the specified cell.
-
getRealPart
public DoubleMatrix1D getRealPart()
Description copied from class:DComplexMatrix1DReturns the real part of this matrix- Specified by:
getRealPartin classDComplexMatrix1D- Returns:
- the real part
-
ifft
public void ifft(boolean scale)
Computes the inverse of the discrete Fourier transform (IDFT) of this matrix. Throws IllegalArgumentException if the size of this matrix is not a power of 2 number.- Parameters:
scale- if true, then scaling is performed.
-
like
public DComplexMatrix1D like(int size)
Description copied from class:DComplexMatrix1DConstruct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size. For example, if the receiver is an instance of type DenseDComplexMatrix1D the new matrix must also be of type DenseDComplexMatrix1D. In general, the new matrix should have internal parametrization as similar as possible.- Specified by:
likein classDComplexMatrix1D- Parameters:
size- the number of cell the matrix shall have.- Returns:
- a new empty matrix of the same dynamic type.
-
like2D
public DComplexMatrix2D like2D(int rows, int columns)
Description copied from class:DComplexMatrix1DConstruct and returns a new 2-d matrix of the corresponding dynamic type, entirely independent of the receiver. For example, if the receiver is an instance of type DenseDComplexMatrix1D the new matrix must be of type DenseDComplexMatrix2D.- Specified by:
like2Din classDComplexMatrix1D- Parameters:
rows- the number of rows the matrix shall have.columns- the number of columns the matrix shall have.- Returns:
- a new matrix of the corresponding dynamic type.
-
reshape
public DComplexMatrix2D reshape(int rows, int columns)
Description copied from class:DComplexMatrix1DReturns new DoubleMatrix2D of size rows x columns whose elements are taken column-wise from this matrix.- Specified by:
reshapein classDComplexMatrix1D- Parameters:
rows- number of rowscolumns- number of columns- Returns:
- new 2D matrix with columns being the elements of this matrix.
-
reshape
public DComplexMatrix3D reshape(int slices, int rows, int columns)
Description copied from class:DComplexMatrix1DReturns new DoubleMatrix3D of size slices x rows x columns, whose elements are taken column-wise from this matrix.- Specified by:
reshapein classDComplexMatrix1Drows- number of rowscolumns- number of columns- Returns:
- new 2D matrix with columns being the elements of this matrix.
-
setQuick
public void setQuick(int index, double re, double im)Description copied from class:DComplexMatrix1DSets the matrix cell at coordinate index to the specified value.Provided with invalid parameters this method may access illegal indexes without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): index<0 || index>=size().
- Specified by:
setQuickin classDComplexMatrix1D- Parameters:
index- the index of the cell.re- the real part of the value to be filled into the specified cell.im- the imaginary part of the value to be filled into the specified cell.
-
setQuick
public void setQuick(int index, double[] value)Description copied from class:DComplexMatrix1DSets the matrix cell at coordinate index to the specified value.Provided with invalid parameters this method may access illegal indexes without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): index<0 || index>=size().
- Specified by:
setQuickin classDComplexMatrix1D- Parameters:
index- the index of the cell.value- the value to be filled into the specified cell (re=value[0], im=value[1]).
-
swap
public void swap(DComplexMatrix1D other)
Description copied from class:DComplexMatrix1DSwaps each element this[i] with other[i].- Overrides:
swapin classDComplexMatrix1D
-
toArray
public void toArray(double[] values)
Description copied from class:DComplexMatrix1DFills the cell values into the specified 1-dimensional array. The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa. After this call returns the array values has the form
for (int i = 0; i < size; i++) { tmp = getQuick(i); values[2 * i] = tmp[0]; //real part values[2 * i + 1] = tmp[1]; //imaginary part }- Overrides:
toArrayin classDComplexMatrix1D
-
zDotProduct
public double[] zDotProduct(DComplexMatrix1D y, int from, int length)
Description copied from class:DComplexMatrix1DReturns the dot product of two vectors x and y. Operates on cells at indexes from .. Min(size(),y.size(),from+length)-1.- Overrides:
zDotProductin classDComplexMatrix1D- Parameters:
y- the second vector.from- the first index to be considered.length- the number of cells to be considered.- Returns:
- the sum of products; zero if from<0 || length<0.
-
zSum
public double[] zSum()
Description copied from class:DComplexMatrix1DReturns the sum of all cells.- Overrides:
zSumin classDComplexMatrix1D- Returns:
- the sum.
-
index
public long index(int rank)
Description copied from class:AbstractMatrix1DReturns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array. You may want to override this method for performance.- Overrides:
indexin classAbstractMatrix1D- Parameters:
rank- the rank of the element.
-
-
DMelt 3.0 © DataMelt by jWork.ORG