public class DenseLongMatrix1D extends LongMatrix1D
Implementation:
Longernally 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 and Description |
|---|
DenseLongMatrix1D(int size)
Constructs a matrix with a given number of cells.
|
DenseLongMatrix1D(int size,
long[] elements,
int zero,
int stride,
boolean isView)
Constructs a matrix with the given parameters.
|
DenseLongMatrix1D(long[] values)
Constructs a matrix with a copy of the given values.
|
| Modifier and Type | Method and Description |
|---|---|
long |
aggregate(LongLongFunction aggr,
LongFunction f)
Applies a function to each cell and aggregates the results.
|
long |
aggregate(LongLongFunction aggr,
LongFunction f,
IntArrayList indexList)
Applies a function to all cells with a given indexes and aggregates the
results.
|
long |
aggregate(LongMatrix1D other,
LongLongFunction aggr,
LongLongFunction f)
Applies a function to each corresponding cell of two matrices and
aggregates the results.
|
LongMatrix1D |
assign(int[] values)
Sets all cells to the state specified by values.
|
LongMatrix1D |
assign(long value)
Sets all cells to the state specified by value.
|
LongMatrix1D |
assign(long[] values)
Sets all cells to the state specified by values.
|
LongMatrix1D |
assign(LongFunction function)
Assigns the result of a function to each cell;
x[i] = function(x[i]).
|
LongMatrix1D |
assign(LongMatrix1D source)
Replaces all cell values of the receiver with the values of another
matrix.
|
LongMatrix1D |
assign(LongMatrix1D y,
LongLongFunction function)
Assigns the result of a function to each cell;
x[i] = function(x[i],y[i]).
|
LongMatrix1D |
assign(LongProcedure cond,
long value)
Assigns a value to all cells that satisfy a condition.
|
LongMatrix1D |
assign(LongProcedure cond,
LongFunction function)
Assigns the result of a function to all cells that satisfy a condition.
|
int |
cardinality()
Returns the number of cells having non-zero values; ignores tolerance.
|
long[] |
elements()
Returns the elements of this matrix.
|
long[] |
getMaxLocation()
Return the maximum value of this matrix together with its location
|
long[] |
getMinLocation()
Return the minimum value of this matrix together with its location
|
void |
getNegativeValues(LongArrayList indexList,
LongArrayList valueList) |
void |
getNonZeros(LongArrayList indexList,
LongArrayList valueList) |
void |
getPositiveValues(LongArrayList indexList,
LongArrayList valueList) |
long |
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.
|
LongMatrix1D |
like(int size)
Construct and returns a new empty matrix of the same dynamic type
as the receiver, having the specified size.
|
LongMatrix2D |
like2D(int rows,
int columns)
Construct and returns a new 2-d matrix of the corresponding dynamic
type, entirelly independent of the receiver.
|
LongMatrix2D |
reshape(int rows,
int columns)
Returns new LongMatrix2D of size rows x columns whose elements are taken
column-wise from this matrix.
|
LongMatrix3D |
reshape(int slices,
int rows,
int columns)
Returns new LongMatrix3D of size slices x rows x columns, whose elements
are taken column-wise from this matrix.
|
void |
setQuick(int index,
long value)
Sets the matrix cell at coordinate index to the specified value.
|
void |
swap(LongMatrix1D other)
Swaps each element this[i] with other[i].
|
void |
toArray(long[] values)
Fills the cell values into the specified 1-dimensional array.
|
long |
zDotProduct(LongMatrix1D y)
Returns the dot product of two vectors x and y, which is
Sum(x[i]*y[i]).
|
long |
zDotProduct(LongMatrix1D y,
int from,
int length)
Returns the dot product of two vectors x and y, which is
Sum(x[i]*y[i]).
|
long |
zSum()
Returns the sum of all cells; Sum( x[i] ).
|
assign, copy, equals, equals, get, getNegativeValues, getNonZeros, getNonZeros, getPositiveValues, like, set, setSize, toArray, toString, viewFlip, viewPart, viewSelection, viewSelection, viewSorted, viewStrides, zDotProductcheckSize, size, stride, toStringShortensureCapacity, isView, trimToSizeclonepublic DenseLongMatrix1D(long[] values)
values - The values to be filled into the new matrix.public DenseLongMatrix1D(int size)
size - the number of cells the matrix shall have.IllegalArgumentException - if size<0.public DenseLongMatrix1D(int size,
long[] elements,
int zero,
int stride,
boolean isView)
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).isView - if true then a matrix view is constructedIllegalArgumentException - if size<0.public long aggregate(LongLongFunction aggr, LongFunction f)
LongMatrix1DExample:
cern.jet.math.Functions F = cern.jet.math.Functions.functions; matrix = 0 1 2 3 // Sum( x[i]*x[i] ) matrix.aggregate(F.plus,F.square); --> 14For further examples, see the package doc.
aggregate in class LongMatrix1Daggr - 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.LongFunctionspublic long aggregate(LongLongFunction aggr, LongFunction f, IntArrayList indexList)
LongMatrix1Daggregate in class LongMatrix1Daggr - 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.LongFunctionspublic long aggregate(LongMatrix1D other, LongLongFunction aggr, LongLongFunction f)
LongMatrix1DExample:
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)); --> 56For further examples, see the package doc.
aggregate in class LongMatrix1Daggr - 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.LongFunctionspublic LongMatrix1D assign(LongFunction function)
LongMatrix1DExample:
// 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.350783For further examples, see the package doc.
assign in class LongMatrix1Dfunction - a function object taking as argument the current cell's value.LongFunctionspublic LongMatrix1D assign(LongProcedure cond, LongFunction function)
LongMatrix1Dassign in class LongMatrix1Dcond - a condition.function - a function object.LongFunctionspublic LongMatrix1D assign(LongProcedure cond, long value)
LongMatrix1Dassign in class LongMatrix1Dcond - a condition.value - a value.public LongMatrix1D assign(long value)
LongMatrix1Dassign in class LongMatrix1Dvalue - the value to be filled into the cells.public LongMatrix1D assign(long[] values)
LongMatrix1DThe values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
assign in class LongMatrix1Dvalues - the values to be filled into the cells.public LongMatrix1D assign(int[] values)
LongMatrix1DThe values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
assign in class LongMatrix1Dvalues - the values to be filled into the cells.public LongMatrix1D assign(LongMatrix1D source)
LongMatrix1Dassign in class LongMatrix1Dsource - the source matrix to copy from (may be identical to the
receiver).public LongMatrix1D assign(LongMatrix1D y, LongLongFunction function)
LongMatrix1DExample:
// 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 729For further examples, see the package doc.
assign in class LongMatrix1Dy - 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,LongFunctionspublic int cardinality()
LongMatrix1Dcardinality in class LongMatrix1Dpublic long[] elements()
LongMatrix1Delements in class LongMatrix1Dpublic void getNonZeros(LongArrayList indexList, LongArrayList valueList)
public void getPositiveValues(LongArrayList indexList, LongArrayList valueList)
public void getNegativeValues(LongArrayList indexList, LongArrayList valueList)
public long[] getMaxLocation()
LongMatrix1DgetMaxLocation in class LongMatrix1Dpublic long[] getMinLocation()
LongMatrix1DgetMinLocation in class LongMatrix1Dpublic long getQuick(int index)
LongMatrix1DProvided 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 LongMatrix1Dindex - the index of the cell.public LongMatrix1D like(int size)
LongMatrix1Dlike in class LongMatrix1Dsize - the number of cell the matrix shall have.public LongMatrix2D like2D(int rows, int columns)
LongMatrix1Dlike2D in class LongMatrix1Drows - the number of rows the matrix shall have.columns - the number of columns the matrix shall have.public LongMatrix2D reshape(int rows, int columns)
LongMatrix1Dreshape in class LongMatrix1Drows - number of rowscolumns - number of columnspublic LongMatrix3D reshape(int slices, int rows, int columns)
LongMatrix1Dreshape in class LongMatrix1Drows - number of rowscolumns - number of columnspublic void setQuick(int index,
long value)
LongMatrix1DProvided 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 LongMatrix1Dindex - the index of the cell.value - the value to be filled into the specified cell.public void swap(LongMatrix1D other)
LongMatrix1Dswap in class LongMatrix1Dpublic void toArray(long[] values)
LongMatrix1DtoArray in class LongMatrix1Dpublic long zDotProduct(LongMatrix1D y)
LongMatrix1DzDotProduct in class LongMatrix1Dy - the second vector.public long zDotProduct(LongMatrix1D y, int from, int length)
LongMatrix1DzDotProduct in class LongMatrix1Dy - the second vector.from - the first index to be considered.length - the number of cells to be considered.public long zSum()
LongMatrix1DzSum in class LongMatrix1Dpublic long index(int rank)
AbstractMatrix1Dindex in class AbstractMatrix1Drank - the rank of the element.Jump to the Parallel Colt Homepage