public class DenseDoubleMatrix1D extends DoubleMatrix1D
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,
Modifier and Type | Field and Description |
---|---|
protected double[] |
elements
The elements of this matrix.
|
size, stride, zero
isNoView
serialVersionUID
Modifier | Constructor and Description |
---|---|
|
DenseDoubleMatrix1D(double[] values)
Constructs a matrix with a copy of the given values.
|
|
DenseDoubleMatrix1D(int size)
Constructs a matrix with a given number of cells.
|
protected |
DenseDoubleMatrix1D(int size,
double[] elements,
int zero,
int stride)
Constructs a matrix view with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
DoubleMatrix1D |
assign(double value)
Sets all cells to the state specified by value.
|
DoubleMatrix1D |
assign(double[] values)
Sets all cells to the state specified by values.
|
DoubleMatrix1D |
assign(DoubleFunction function)
Assigns the result of a function to each cell; x[i] = function(x[i]).
|
DoubleMatrix1D |
assign(DoubleMatrix1D source)
Replaces all cell values of the receiver with the values of another matrix.
|
DoubleMatrix1D |
assign(DoubleMatrix1D y,
DoubleDoubleFunction function)
Assigns the result of a function to each cell; x[i] = function(x[i],y[i]).
|
protected int |
cardinality(int maxCardinality)
Returns the number of cells having non-zero values, but at most maxCardinality; ignores tolerance.
|
double |
getQuick(int index)
Returns the matrix cell value at coordinate index.
|
protected boolean |
haveSharedCellsRaw(DoubleMatrix1D other)
Returns true if both matrices share at least one identical cell.
|
protected int |
index(int rank)
Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array.
|
DoubleMatrix1D |
like(int size)
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size.
|
DoubleMatrix2D |
like2D(int rows,
int columns)
Construct and returns a new 2-d matrix of the corresponding dynamic type, entirelly independent of the receiver.
|
void |
setQuick(int index,
double value)
Sets the matrix cell at coordinate index to the specified value.
|
void |
swap(DoubleMatrix1D other)
Swaps each element this[i] with other[i].
|
void |
toArray(double[] values)
Fills the cell values into the specified 1-dimensional array.
|
protected DoubleMatrix1D |
viewSelectionLike(int[] offsets)
Construct and returns a new selection view.
|
double |
zDotProduct(DoubleMatrix1D y,
int from,
int length)
Returns the dot product of two vectors x and y, which is Sum(x[i]*y[i]).
|
double |
zSum()
Returns the sum of all cells; Sum( x[i] ).
|
aggregate, aggregate, assign, cardinality, copy, equals, equals, get, getContent, getNonZeros, getNonZeros, haveSharedCells, like, set, toArray, toString, view, viewFlip, viewPart, viewSelection, viewSelection, viewSorted, viewStrides, zDotProduct, zDotProduct, zDotProduct
_offset, _rank, checkIndex, checkIndexes, checkRange, checkSize, checkSize, setUp, setUp, size, stride, toStringShort, vFlip, vPart, vStrides
ensureCapacity, isView, trimToSize
clone
public DenseDoubleMatrix1D(double[] values)
values
- The values to be filled into the new matrix.public DenseDoubleMatrix1D(int size)
size
- the number of cells the matrix shall have.IllegalArgumentException
- if size<0.protected DenseDoubleMatrix1D(int size, double[] elements, int zero, int stride)
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).IllegalArgumentException
- if size<0.public DoubleMatrix1D assign(double[] values)
The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
assign
in class DoubleMatrix1D
values
- the values to be filled into the cells.IllegalArgumentException
- if values.length != size().public DoubleMatrix1D assign(double value)
assign
in class DoubleMatrix1D
value
- the value to be filled into the cells.public DoubleMatrix1D assign(DoubleFunction 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.350783For further examples, see the package doc.
assign
in class DoubleMatrix1D
function
- a function object taking as argument the current cell's value.Functions
public DoubleMatrix1D assign(DoubleMatrix1D source)
assign
in class DoubleMatrix1D
source
- the source matrix to copy from (may be identical to the receiver).IllegalArgumentException
- if size() != other.size().public DoubleMatrix1D assign(DoubleMatrix1D y, DoubleDoubleFunction function)
Example:
// assign x[i] = x[i]y[i] 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 DoubleDoubleFunction() { public double apply(double x, double y) { return Math.pow(x,y); } } );For further examples, see the package doc.
assign
in class DoubleMatrix1D
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,IllegalArgumentException
- if size() != y.size().Functions
protected int cardinality(int maxCardinality)
cardinality
in class DoubleMatrix1D
public double 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 DoubleMatrix1D
index
- the index of the cell.protected boolean haveSharedCellsRaw(DoubleMatrix1D other)
haveSharedCellsRaw
in class DoubleMatrix1D
protected int index(int rank)
index
in class AbstractMatrix1D
rank
- the rank of the element.public DoubleMatrix1D like(int size)
like
in class DoubleMatrix1D
size
- the number of cell the matrix shall have.public DoubleMatrix2D like2D(int rows, int columns)
like2D
in class DoubleMatrix1D
rows
- the number of rows the matrix shall have.columns
- the number of columns the matrix shall have.public void setQuick(int index, double 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 DoubleMatrix1D
index
- the index of the cell.value
- the value to be filled into the specified cell.public void swap(DoubleMatrix1D other)
swap
in class DoubleMatrix1D
IllegalArgumentException
- if size() != other.size().public void toArray(double[] values)
toArray
in class DoubleMatrix1D
IllegalArgumentException
- if values.length < size().protected DoubleMatrix1D viewSelectionLike(int[] offsets)
viewSelectionLike
in class DoubleMatrix1D
offsets
- the offsets of the visible elements.public double zDotProduct(DoubleMatrix1D y, int from, int length)
zDotProduct
in class DoubleMatrix1D
y
- the second vector.from
- the first index to be considered.length
- the number of cells to be considered.public double zSum()
zSum
in class DoubleMatrix1D
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.