|
|||||||||
| PREV CLASS NEXT CLASS | All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcern.colt.PersistentObject
cern.colt.matrix.AbstractMatrix
cern.colt.matrix.AbstractMatrix1D
cern.colt.matrix.tobject.ObjectMatrix1D
cern.colt.matrix.tobject.impl.DenseObjectMatrix1D
public class DenseObjectMatrix1D
Dense 1-d matrix (aka vector) holding Object elements. First see the package summary and javadoc tree view to get the broad picture.
Implementation:
Internally holds one single contigous one-dimensional array. Note that this implementation is not synchronized.
Memory requirements:
memory [bytes] = 8*size(). Thus, a 1000000 matrix uses 8 MB.
Time complexity:
O(1) (i.e. constant time) for the basic operations get, getQuick, set, setQuick and size,
| Constructor Summary | |
|---|---|
DenseObjectMatrix1D(int size)
Constructs a matrix with a given number of cells. |
|
DenseObjectMatrix1D(Object[] values)
Constructs a matrix with a copy of the given values. |
|
| Method Summary | |
|---|---|
Object |
aggregate(ObjectMatrix1D other,
ObjectObjectFunction aggr,
ObjectObjectFunction f)
Applies a function to each corresponding cell of two matrices and aggregates the results. |
Object |
aggregate(ObjectObjectFunction aggr,
ObjectFunction f)
Applies a function to each cell and aggregates the results. |
Object |
aggregate(ObjectObjectFunction aggr,
ObjectFunction f,
IntArrayList indexList)
Applies a function to all cells with a given indexes and aggregates the results. |
ObjectMatrix1D |
assign(Object value)
Sets all cells to the state specified by value. |
ObjectMatrix1D |
assign(Object[] values)
Sets all cells to the state specified by values. |
ObjectMatrix1D |
assign(ObjectFunction function)
Assigns the result of a function to each cell; x[i] = function(x[i]). |
ObjectMatrix1D |
assign(ObjectMatrix1D source)
Replaces all cell values of the receiver with the values of another matrix. |
ObjectMatrix1D |
assign(ObjectMatrix1D y,
ObjectObjectFunction function)
Assigns the result of a function to each cell; x[i] = function(x[i],y[i]). |
Object |
elements()
Returns the elements of this matrix. |
Object |
getQuick(int index)
Returns the matrix cell value at coordinate index. |
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. |
ObjectMatrix1D |
like(int size)
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size. |
ObjectMatrix2D |
like2D(int rows,
int columns)
Construct and returns a new 2-d matrix of the corresponding dynamic type, entirelly independent of the receiver. |
ObjectMatrix2D |
reshape(int rows,
int columns)
Returns new ObjectMatrix2D of size rows x columns whose elements are taken column-wise from this matrix. |
ObjectMatrix3D |
reshape(int slices,
int rows,
int columns)
Returns new ObjectMatrix3D of size slices x rows x columns, whose elements are taken column-wise from this matrix. |
void |
setQuick(int index,
Object value)
Sets the matrix cell at coordinate index to the specified value. |
void |
swap(ObjectMatrix1D other)
Swaps each element this[i] with other[i]. |
void |
toArray(Object[] values)
Fills the cell values into the specified 1-dimensional array. |
| Methods inherited from class cern.colt.matrix.tobject.ObjectMatrix1D |
|---|
cardinality, copy, equals, equals, get, getNonZeros, like, set, setSize, toArray, toString, viewFlip, viewPart, viewSelection, viewSelection, viewSorted, viewStrides |
| 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 |
|---|
public DenseObjectMatrix1D(Object[] values)
values - The values to be filled into the new matrix.public DenseObjectMatrix1D(int size)
size - the number of cells the matrix shall have.
IllegalArgumentException - if size<0.| Method Detail |
|---|
public Object aggregate(ObjectObjectFunction aggr,
ObjectFunction f)
ObjectMatrix1D
aggregate in class ObjectMatrix1Daggr - 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.
public Object aggregate(ObjectObjectFunction aggr,
ObjectFunction f,
IntArrayList indexList)
ObjectMatrix1D
aggregate in class ObjectMatrix1Daggr - 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.indexList - indexes.
public Object aggregate(ObjectMatrix1D other,
ObjectObjectFunction aggr,
ObjectObjectFunction f)
ObjectMatrix1DExample:
cern.jet.math.Functions F = cern.jet.math.Functions.functions;
x = 0 1 2 3
y = 0 1 2 3
// Sum( x[i]*y[i] )
x.aggregate(y, F.plus, F.mult);
--> 14
// Sum( (x[i]+y[i])ˆ2 )
x.aggregate(y, F.plus, F.chain(F.square,F.plus));
--> 56
For further examples, see the package doc.
aggregate in class ObjectMatrix1Daggr - 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.
public ObjectMatrix1D assign(Object[] values)
The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
assign in class ObjectMatrix1Dvalues - the values to be filled into the cells.
IllegalArgumentException - if values.length != size().public ObjectMatrix1D assign(ObjectFunction function)
Example:
// change each cell to its sine
matrix = 0.5 1.5 2.5 3.5
matrix.assign(cern.jet.math.Functions.sin);
-->
matrix == 0.479426 0.997495 0.598472 -0.350783
For further examples, see the package doc.
assign in class ObjectMatrix1Dfunction - a function object taking as argument the current cell's value.
DoubleFunctionspublic ObjectMatrix1D assign(ObjectMatrix1D source)
assign in class ObjectMatrix1Dsource - the source matrix to copy from (may be identical to the
receiver).
IllegalArgumentException - if size() != other.size().
public ObjectMatrix1D assign(ObjectMatrix1D y,
ObjectObjectFunction function)
Example:
// assign x[i] = x[i]<sup>y[i]</sup>
m1 = 0 1 2 3;
m2 = 0 2 4 6;
m1.assign(m2, cern.jet.math.Functions.pow);
-->
m1 == 1 1 16 729
// for non-standard functions there is no shortcut:
m1.assign(m2,
new ObjectobjectFunction() {
public Object apply(Object x, Object y) { return Math.pow(x,y); }
}
);
For further examples, see the package doc.
assign in class ObjectMatrix1Dy - 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,
IllegalArgumentException - if size() != y.size().DoubleFunctionspublic ObjectMatrix1D assign(Object value)
ObjectMatrix1D
assign in class ObjectMatrix1Dvalue - the value to be filled into the cells.
public Object elements()
ObjectMatrix1D
elements in class ObjectMatrix1Dpublic Object getQuick(int 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().
getQuick in class ObjectMatrix1Dindex - the index of the cell.
public long index(int rank)
index in class AbstractMatrix1Drank - the rank of the element.public ObjectMatrix1D like(int size)
like in class ObjectMatrix1Dsize - the number of cell the matrix shall have.
public ObjectMatrix2D like2D(int rows,
int columns)
like2D in class ObjectMatrix1Drows - the number of rows the matrix shall have.columns - the number of columns the matrix shall have.
public ObjectMatrix2D reshape(int rows,
int columns)
ObjectMatrix1D
reshape in class ObjectMatrix1Drows - number of rowscolumns - number of columns
public ObjectMatrix3D reshape(int slices,
int rows,
int columns)
ObjectMatrix1D
reshape in class ObjectMatrix1Drows - number of rowscolumns - number of columns
public void setQuick(int index,
Object 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().
setQuick in class ObjectMatrix1Dindex - the index of the cell.value - the value to be filled into the specified cell.public void swap(ObjectMatrix1D other)
swap in class ObjectMatrix1DIllegalArgumentException - if size() != other.size().public void toArray(Object[] values)
toArray in class ObjectMatrix1DIllegalArgumentException - if values.length < size().
|
|||||||||
| PREV CLASS NEXT CLASS | All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||