Parallel Colt 0.7.2

cern.colt.matrix.tfcomplex.impl
Class DenseFComplexMatrix1D

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.colt.matrix.AbstractMatrix
          extended by cern.colt.matrix.AbstractMatrix1D
              extended by cern.colt.matrix.tfcomplex.FComplexMatrix1D
                  extended by cern.colt.matrix.tfcomplex.impl.DenseFComplexMatrix1D
All Implemented Interfaces:
Serializable, Cloneable

public class DenseFComplexMatrix1D
extends FComplexMatrix1D

Dense 1-d matrix (aka vector) holding complex elements. Implementation:

Internally holds one single contiguous one-dimensional array. Complex data is represented by 2 float 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).

Memory requirements:

memory [bytes] = 8*2*size(). Thus, a 1000000 matrix uses 16 MB.

Time complexity:

O(1) (i.e. constant time) for the basic operations get, getQuick, set, setQuick and size,

Author:
Piotr Wendykier (piotr.wendykier@gmail.com)
See Also:
Serialized Form

Constructor Summary
DenseFComplexMatrix1D(float[] values)
          Constructs a matrix with a copy of the given values.
DenseFComplexMatrix1D(FloatMatrix1D realPart)
          Constructs a complex matrix with the same size as realPart matrix and fills the real part of this matrix with elements of realPart.
DenseFComplexMatrix1D(int size)
          Constructs a matrix with a given number of cells.
DenseFComplexMatrix1D(int size, float[] elements, int zero, int stride)
          Constructs a matrix view with the given parameters.
 
Method Summary
 float[] aggregate(FComplexFComplexFComplexFunction aggr, FComplexFComplexFunction f)
          Applies a function to each cell and aggregates the results.
 float[] aggregate(FComplexMatrix1D other, FComplexFComplexFComplexFunction aggr, FComplexFComplexFComplexFunction f)
          Applies a function to each corresponding cell of two matrices and aggregates the results.
 FComplexMatrix1D assign(FComplexFComplexFunction function)
          Assigns the result of a function to each cell;
 FComplexMatrix1D assign(FComplexMatrix1D source)
          Replaces all cell values of the receiver with the values of another matrix.
 FComplexMatrix1D assign(FComplexMatrix1D y, FComplexFComplexFComplexFunction function)
          Assigns the result of a function to each cell;
 FComplexMatrix1D assign(FComplexProcedure cond, FComplexFComplexFunction function)
          Assigns the result of a function to all cells that satisfy a condition.
 FComplexMatrix1D assign(FComplexProcedure cond, float[] value)
          Assigns a value to all cells that satisfy a condition.
 FComplexMatrix1D assign(FComplexRealFunction function)
          Assigns the result of a function to the real part of the receiver.
 FComplexMatrix1D assign(float[] values)
          Sets all cells to the state specified by values.
 FComplexMatrix1D assign(float re, float im)
          Sets all cells to the state specified by re and im.
 FComplexMatrix1D assignImaginary(FloatMatrix1D other)
          Replaces imaginary part of the receiver with the values of another real matrix.
 FComplexMatrix1D assignReal(FloatMatrix1D other)
          Replaces real part of the receiver with the values of another real matrix.
 float[] elements()
          Returns the elements of this matrix.
 void fft()
          Computes the discrete Fourier transform (DFT) of this matrix.
 FloatMatrix1D getImaginaryPart()
          Returns the imaginary part of this matrix
 void getNonZeros(IntArrayList indexList, ArrayList<float[]> valueList)
          Fills the coordinates and values of cells having non-zero values into the specified lists.
 float[] getQuick(int index)
          Returns the matrix cell value at coordinate index.
 FloatMatrix1D getRealPart()
          Returns the real part of this matrix
 void ifft(boolean scale)
          Computes the inverse of the discrete Fourier transform (IDFT) of this matrix.
 long index(int rank)
          Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array.
 FComplexMatrix1D like(int size)
          Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size.
 FComplexMatrix2D like2D(int rows, int columns)
          Construct and returns a new 2-d matrix of the corresponding dynamic type, entirely independent of the receiver.
 FComplexMatrix2D reshape(int rows, int cols)
          Returns new FloatMatrix2D of size rows x columns whose elements are taken column-wise from this matrix.
 FComplexMatrix3D reshape(int slices, int rows, int cols)
          Returns new FloatMatrix3D of size slices x rows x columns, whose elements are taken column-wise from this matrix.
 void setQuick(int index, float[] value)
          Sets the matrix cell at coordinate index to the specified value.
 void setQuick(int index, float re, float im)
          Sets the matrix cell at coordinate index to the specified value.
 void swap(FComplexMatrix1D other)
          Swaps each element this[i] with other[i].
 void toArray(float[] values)
          Fills the cell values into the specified 1-dimensional array.
 float[] zSum()
          Returns the sum of all cells.
 
Methods inherited from class cern.colt.matrix.tfcomplex.FComplexMatrix1D
cardinality, copy, equals, equals, get, like, set, set, toArray, toString, toString, viewFlip, viewPart, viewSelection, viewSelection, viewStrides, zDotProduct, 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
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DenseFComplexMatrix1D

public DenseFComplexMatrix1D(float[] 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 float 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.

DenseFComplexMatrix1D

public DenseFComplexMatrix1D(FloatMatrix1D 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:
IllegalArgumentException - if size<0.

DenseFComplexMatrix1D

public DenseFComplexMatrix1D(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:
IllegalArgumentException - if size<0.

DenseFComplexMatrix1D

public DenseFComplexMatrix1D(int size,
                             float[] elements,
                             int zero,
                             int stride)
Constructs a matrix view 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).
Throws:
IllegalArgumentException - if size<0.
Method Detail

aggregate

public float[] aggregate(FComplexFComplexFComplexFunction aggr,
                         FComplexFComplexFunction f)
Description copied from class: FComplexMatrix1D
Applies a function to each cell and aggregates the results.

Overrides:
aggregate in class FComplexMatrix1D
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:
FComplexFunctions

aggregate

public float[] aggregate(FComplexMatrix1D other,
                         FComplexFComplexFComplexFunction aggr,
                         FComplexFComplexFComplexFunction f)
Description copied from class: FComplexMatrix1D
Applies a function to each corresponding cell of two matrices and aggregates the results.

Overrides:
aggregate in class FComplexMatrix1D
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:
FComplexFunctions

assign

public FComplexMatrix1D assign(FComplexFComplexFunction function)
Description copied from class: FComplexMatrix1D
Assigns the result of a function to each cell;

Overrides:
assign in class FComplexMatrix1D
Parameters:
function - a function object taking as argument the current cell's value.
Returns:
this (for convenience only).
See Also:
FComplexFunctions

assign

public FComplexMatrix1D assign(FComplexProcedure cond,
                               FComplexFComplexFunction function)
Description copied from class: FComplexMatrix1D
Assigns the result of a function to all cells that satisfy a condition.

Overrides:
assign in class FComplexMatrix1D
Parameters:
cond - a condition.
function - a function object.
Returns:
this (for convenience only).
See Also:
FComplexFunctions

assign

public FComplexMatrix1D assign(FComplexProcedure cond,
                               float[] value)
Description copied from class: FComplexMatrix1D
Assigns a value to all cells that satisfy a condition.

Overrides:
assign in class FComplexMatrix1D
Parameters:
cond - a condition.
value - a value (re=value[0], im=value[1]).
Returns:
this (for convenience only).

assign

public FComplexMatrix1D assign(FComplexRealFunction function)
Description copied from class: FComplexMatrix1D
Assigns the result of a function to the real part of the receiver. The imaginary part of the receiver is reset to zero.

Overrides:
assign in class FComplexMatrix1D
Parameters:
function - a function object taking as argument the current cell's value.
Returns:
this (for convenience only).
See Also:
FComplexFunctions

assign

public FComplexMatrix1D assign(FComplexMatrix1D source)
Description copied from class: FComplexMatrix1D
Replaces 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:
assign in class FComplexMatrix1D
Parameters:
source - the source matrix to copy from (may be identical to the receiver).
Returns:
this (for convenience only).

assign

public FComplexMatrix1D assign(FComplexMatrix1D y,
                               FComplexFComplexFComplexFunction function)
Description copied from class: FComplexMatrix1D
Assigns the result of a function to each cell;

Overrides:
assign in class FComplexMatrix1D
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:
FComplexFunctions

assign

public FComplexMatrix1D assign(float re,
                               float im)
Description copied from class: FComplexMatrix1D
Sets all cells to the state specified by re and im.

Overrides:
assign in class FComplexMatrix1D
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 FComplexMatrix1D assign(float[] values)
Description copied from class: FComplexMatrix1D
Sets 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 float 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:
assign in class FComplexMatrix1D
Parameters:
values - the values to be filled into the cells.
Returns:
this (for convenience only).

assignImaginary

public FComplexMatrix1D assignImaginary(FloatMatrix1D other)
Description copied from class: FComplexMatrix1D
Replaces 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:
assignImaginary in class FComplexMatrix1D
Parameters:
other - the source matrix to copy from
Returns:
this (for convenience only).

assignReal

public FComplexMatrix1D assignReal(FloatMatrix1D other)
Description copied from class: FComplexMatrix1D
Replaces 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:
assignReal in class FComplexMatrix1D
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 float[] elements()
Description copied from class: FComplexMatrix1D
Returns the elements of this matrix.

Specified by:
elements in class FComplexMatrix1D
Returns:
the elements

getImaginaryPart

public FloatMatrix1D getImaginaryPart()
Description copied from class: FComplexMatrix1D
Returns the imaginary part of this matrix

Specified by:
getImaginaryPart in class FComplexMatrix1D
Returns:
the imaginary part

getNonZeros

public void getNonZeros(IntArrayList indexList,
                        ArrayList<float[]> valueList)
Description copied from class: FComplexMatrix1D
Fills 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:
getNonZeros in class FComplexMatrix1D
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 float[] getQuick(int index)
Description copied from class: FComplexMatrix1D
Returns 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:
getQuick in class FComplexMatrix1D
Parameters:
index - the index of the cell.
Returns:
the value of the specified cell.

getRealPart

public FloatMatrix1D getRealPart()
Description copied from class: FComplexMatrix1D
Returns the real part of this matrix

Specified by:
getRealPart in class FComplexMatrix1D
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 FComplexMatrix1D like(int size)
Description copied from class: FComplexMatrix1D
Construct 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 DenseFComplexMatrix1D the new matrix must also be of type DenseFComplexMatrix1D. In general, the new matrix should have internal parametrization as similar as possible.

Specified by:
like in class FComplexMatrix1D
Parameters:
size - the number of cell the matrix shall have.
Returns:
a new empty matrix of the same dynamic type.

like2D

public FComplexMatrix2D like2D(int rows,
                               int columns)
Description copied from class: FComplexMatrix1D
Construct 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 DenseFComplexMatrix1D the new matrix must be of type DenseFComplexMatrix2D.

Specified by:
like2D in class FComplexMatrix1D
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 FComplexMatrix2D reshape(int rows,
                                int cols)
Description copied from class: FComplexMatrix1D
Returns new FloatMatrix2D of size rows x columns whose elements are taken column-wise from this matrix.

Specified by:
reshape in class FComplexMatrix1D
Parameters:
rows - number of rows
cols - number of columns
Returns:
new 2D matrix with columns being the elements of this matrix.

reshape

public FComplexMatrix3D reshape(int slices,
                                int rows,
                                int cols)
Description copied from class: FComplexMatrix1D
Returns new FloatMatrix3D of size slices x rows x columns, whose elements are taken column-wise from this matrix.

Specified by:
reshape in class FComplexMatrix1D
rows - number of rows
cols - number of columns
Returns:
new 2D matrix with columns being the elements of this matrix.

setQuick

public void setQuick(int index,
                     float re,
                     float im)
Description copied from class: FComplexMatrix1D
Sets 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:
setQuick in class FComplexMatrix1D
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,
                     float[] value)
Description copied from class: FComplexMatrix1D
Sets 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:
setQuick in class FComplexMatrix1D
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(FComplexMatrix1D other)
Description copied from class: FComplexMatrix1D
Swaps each element this[i] with other[i].

Overrides:
swap in class FComplexMatrix1D

toArray

public void toArray(float[] values)
Description copied from class: FComplexMatrix1D
Fills 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:
toArray in class FComplexMatrix1D

zSum

public float[] zSum()
Description copied from class: FComplexMatrix1D
Returns the sum of all cells.

Overrides:
zSum in class FComplexMatrix1D
Returns:
the sum.

index

public long index(int rank)
Description copied from class: AbstractMatrix1D
Returns 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:
index in class AbstractMatrix1D
Parameters:
rank - the rank of the element.

Parallel Colt 0.7.2

Jump to the Parallel Colt Homepage