Parallel Colt 0.9.4

cern.colt.matrix.tdcomplex.impl
Class DenseDComplexMatrix1D

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.tdcomplex.DComplexMatrix1D
                  extended by cern.colt.matrix.tdcomplex.impl.DenseDComplexMatrix1D
All Implemented Interfaces:
Serializable, 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).

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

Constructor Summary
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
 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.
 DComplexMatrix1D assign(DComplexDComplexFunction function)
          Assigns the result of a function to each cell;
 DComplexMatrix1D assign(DComplexMatrix1D source)
          Replaces all cell values of the receiver with the values of another matrix.
 DComplexMatrix1D assign(DComplexMatrix1D y, DComplexDComplexDComplexFunction function)
          Assigns the result of a function to each cell;
 DComplexMatrix1D assign(DComplexProcedure cond, DComplexDComplexFunction function)
          Assigns the result of a function to all cells that satisfy a condition.
 DComplexMatrix1D assign(DComplexProcedure cond, double[] value)
          Assigns a value to all cells that satisfy a condition.
 DComplexMatrix1D assign(DComplexRealFunction function)
          Assigns the result of a function to the real part of the receiver.
 DComplexMatrix1D assign(double[] values)
          Sets all cells to the state specified by values.
 DComplexMatrix1D assign(double re, double im)
          Sets all cells to the state specified by re and im.
 DComplexMatrix1D assignImaginary(DoubleMatrix1D other)
          Replaces imaginary part of the receiver with the values of another real matrix.
 DComplexMatrix1D assignReal(DoubleMatrix1D other)
          Replaces real part of the receiver with the values of another real matrix.
 double[] elements()
          Returns the elements of this matrix.
 void fft()
          Computes the discrete Fourier transform (DFT) of this matrix.
 DoubleMatrix1D getImaginaryPart()
          Returns the imaginary part of this matrix
 void getNonZeros(IntArrayList indexList, 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.
 DoubleMatrix1D 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.
 DComplexMatrix1D like(int size)
          Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size.
 DComplexMatrix2D like2D(int rows, int columns)
          Construct and returns a new 2-d matrix of the corresponding dynamic type, entirely independent of the receiver.
 DComplexMatrix2D reshape(int rows, int columns)
          Returns new DoubleMatrix2D of size rows x columns whose elements are taken column-wise from this matrix.
 DComplexMatrix3D reshape(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.
 void setQuick(int index, double[] value)
          Sets the matrix cell at coordinate index to the specified value.
 void setQuick(int index, double re, double im)
          Sets the matrix cell at coordinate index to the specified value.
 void swap(DComplexMatrix1D other)
          Swaps each element this[i] with other[i].
 void toArray(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
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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:
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:
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:
IllegalArgumentException - if size<0.
Method Detail

aggregate

public double[] aggregate(DComplexDComplexDComplexFunction aggr,
                          DComplexDComplexFunction f)
Description copied from class: DComplexMatrix1D
Applies a function to each cell and aggregates the results.

Overrides:
aggregate in class DComplexMatrix1D
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: DComplexMatrix1D
Applies a function to each corresponding cell of two matrices and aggregates the results.

Overrides:
aggregate in class DComplexMatrix1D
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: DComplexMatrix1D
Assigns the result of a function to each cell;

Overrides:
assign in class DComplexMatrix1D
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: DComplexMatrix1D
Assigns the result of a function to all cells that satisfy a condition.

Overrides:
assign in class DComplexMatrix1D
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: DComplexMatrix1D
Assigns a value to all cells that satisfy a condition.

Overrides:
assign in class DComplexMatrix1D
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: DComplexMatrix1D
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 DComplexMatrix1D
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: DComplexMatrix1D
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 DComplexMatrix1D
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: DComplexMatrix1D
Assigns the result of a function to each cell;

Overrides:
assign in class DComplexMatrix1D
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: DComplexMatrix1D
Sets all cells to the state specified by re and im.

Overrides:
assign in class DComplexMatrix1D
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: DComplexMatrix1D
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 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:
assign in class DComplexMatrix1D
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: DComplexMatrix1D
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 DComplexMatrix1D
Parameters:
other - the source matrix to copy from
Returns:
this (for convenience only).

assignReal

public DComplexMatrix1D assignReal(DoubleMatrix1D other)
Description copied from class: DComplexMatrix1D
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 DComplexMatrix1D
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: DComplexMatrix1D
Returns the elements of this matrix.

Specified by:
elements in class DComplexMatrix1D
Returns:
the elements

getImaginaryPart

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

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

getNonZeros

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

getRealPart

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

Specified by:
getRealPart in class DComplexMatrix1D
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: DComplexMatrix1D
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 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:
like in class DComplexMatrix1D
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: DComplexMatrix1D
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 DenseDComplexMatrix1D the new matrix must be of type DenseDComplexMatrix2D.

Specified by:
like2D in class DComplexMatrix1D
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: DComplexMatrix1D
Returns new DoubleMatrix2D of size rows x columns whose elements are taken column-wise from this matrix.

Specified by:
reshape in class DComplexMatrix1D
Parameters:
rows - number of rows
columns - 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: DComplexMatrix1D
Returns new DoubleMatrix3D of size slices x rows x columns, whose elements are taken column-wise from this matrix.

Specified by:
reshape in class DComplexMatrix1D
rows - number of rows
columns - 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: DComplexMatrix1D
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 DComplexMatrix1D
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: DComplexMatrix1D
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 DComplexMatrix1D
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: DComplexMatrix1D
Swaps each element this[i] with other[i].

Overrides:
swap in class DComplexMatrix1D

toArray

public void toArray(double[] values)
Description copied from class: DComplexMatrix1D
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 DComplexMatrix1D

zDotProduct

public double[] zDotProduct(DComplexMatrix1D y,
                            int from,
                            int length)
Description copied from class: DComplexMatrix1D
Returns the dot product of two vectors x and y. Operates on cells at indexes from .. Min(size(),y.size(),from+length)-1.

Overrides:
zDotProduct in class DComplexMatrix1D
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: DComplexMatrix1D
Returns the sum of all cells.

Overrides:
zSum in class DComplexMatrix1D
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.9.4

Jump to the Parallel Colt Homepage