|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.matrix.impl.AbstractMatrix
org.apache.mahout.math.matrix.impl.AbstractMatrix1D
org.apache.mahout.math.matrix.DoubleMatrix1D
@Deprecated public abstract class DoubleMatrix1D
Field Summary |
---|
Fields inherited from class org.apache.mahout.math.matrix.impl.AbstractMatrix1D |
---|
size, stride, zero |
Fields inherited from class org.apache.mahout.math.matrix.impl.AbstractMatrix |
---|
isNoView |
Constructor Summary | |
---|---|
protected |
DoubleMatrix1D()
Deprecated. Makes this class non instantiable, but still let's others inherit from it. |
Method Summary | |
---|---|
double |
aggregate(DoubleDoubleFunction aggr,
DoubleFunction f)
Deprecated. Applies a function to each cell and aggregates the results. |
double |
aggregate(DoubleMatrix1D other,
DoubleDoubleFunction aggr,
DoubleDoubleFunction f)
Deprecated. Applies a function to each corresponding cell of two matrices and aggregates the results. |
void |
assign(double value)
Deprecated. Sets all cells to the state specified by value. |
void |
assign(double[] values)
Deprecated. Sets all cells to the state specified by values. |
void |
assign(DoubleFunction function)
Deprecated. Assigns the result of a function to each cell; x[i] = function(x[i]). |
DoubleMatrix1D |
assign(DoubleMatrix1D other)
Deprecated. Replaces all cell values of the receiver with the values of another matrix. |
DoubleMatrix1D |
assign(DoubleMatrix1D y,
DoubleDoubleFunction function)
Deprecated. Assigns the result of a function to each cell; x[i] = function(x[i],y[i]). |
void |
assign(DoubleMatrix1D y,
DoubleDoubleFunction function,
org.apache.mahout.math.list.IntArrayList nonZeroIndexes)
Deprecated. Assigns the result of a function to each cell; x[i] = function(x[i],y[i]). |
int |
cardinality()
Deprecated. Returns the number of cells having non-zero values; ignores tolerance. |
protected int |
cardinality(int maxCardinality)
Deprecated. Returns the number of cells having non-zero values, but at most maxCardinality; ignores tolerance. |
DoubleMatrix1D |
copy()
Deprecated. Constructs and returns a deep copy of the receiver. |
boolean |
equals(double value)
Deprecated. Returns whether all cells are equal to the given value. |
boolean |
equals(Object obj)
Deprecated. Compares this object against the specified object. |
double |
get(int index)
Deprecated. Returns the matrix cell value at coordinate index. |
protected DoubleMatrix1D |
getContent()
Deprecated. Returns the content of this matrix if it is a wrapper; or this otherwise. |
void |
getNonZeros(org.apache.mahout.math.list.IntArrayList indexList,
org.apache.mahout.math.list.DoubleArrayList valueList)
Deprecated. Fills the coordinates and values of cells having non-zero values into the specified lists. |
void |
getNonZeros(org.apache.mahout.math.list.IntArrayList indexList,
org.apache.mahout.math.list.DoubleArrayList valueList,
int maxCardinality)
Deprecated. Fills the coordinates and values of cells having non-zero values into the specified lists. |
abstract double |
getQuick(int index)
Deprecated. Returns the matrix cell value at coordinate index. |
protected boolean |
haveSharedCells(DoubleMatrix1D other)
Deprecated. Returns true if both matrices share at least one identical cell. |
protected boolean |
haveSharedCellsRaw(DoubleMatrix1D other)
Deprecated. Returns true if both matrices share at least one identical cell. |
DoubleMatrix1D |
like()
Deprecated. Construct and returns a new empty matrix of the same dynamic type as the receiver, having the same size. |
abstract DoubleMatrix1D |
like(int size)
Deprecated. Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size. |
abstract DoubleMatrix2D |
like2D(int rows,
int columns)
Deprecated. Construct and returns a new 2-d matrix of the corresponding dynamic type, entirelly independent of the receiver. |
void |
set(int index,
double value)
Deprecated. Sets the matrix cell at coordinate index to the specified value. |
abstract void |
setQuick(int index,
double value)
Deprecated. Sets the matrix cell at coordinate index to the specified value. |
void |
swap(DoubleMatrix1D other)
Deprecated. Swaps each element this[i] with other[i]. |
double[] |
toArray()
Deprecated. Constructs and returns a 1-dimensional array containing the cell values. |
void |
toArray(double[] values)
Deprecated. Fills the cell values into the specified 1-dimensional array. |
Vector |
toVector()
Deprecated. |
protected DoubleMatrix1D |
view()
Deprecated. Constructs and returns a new view equal to the receiver. |
DoubleMatrix1D |
viewPart(int index,
int width)
Deprecated. Constructs and returns a new sub-range view that is a width sub matrix starting at index. |
protected abstract DoubleMatrix1D |
viewSelectionLike(int[] offsets)
Deprecated. Construct and returns a new selection view. |
double |
zDotProduct(DoubleMatrix1D y)
Deprecated. Returns the dot product of two vectors x and y, which is Sum(x[i]*y[i]). |
protected double |
zDotProduct(DoubleMatrix1D y,
org.apache.mahout.math.list.IntArrayList nonZeroIndexes)
Deprecated. Returns the dot product of two vectors x and y, which is Sum(x[i]*y[i]). |
double |
zDotProduct(DoubleMatrix1D y,
int from,
int length)
Deprecated. Returns the dot product of two vectors x and y, which is Sum(x[i]*y[i]). |
double |
zDotProduct(DoubleMatrix1D y,
int from,
int length,
org.apache.mahout.math.list.IntArrayList nonZeroIndexes)
Deprecated. Returns the dot product of two vectors x and y, which is Sum(x[i]*y[i]). |
double |
zSum()
Deprecated. Returns the sum of all cells; Sum( x[i] ). |
Methods inherited from class org.apache.mahout.math.matrix.impl.AbstractMatrix1D |
---|
checkIndex, checkRange, checkSize, index, offset, rank, setUp, setUp, size, stride, vPart |
Methods inherited from class org.apache.mahout.math.matrix.impl.AbstractMatrix |
---|
ensureCapacity |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DoubleMatrix1D()
Method Detail |
---|
public double aggregate(DoubleDoubleFunction aggr, DoubleFunction f)
Example:
org.apache.mahout.math.function.Functions F = org.apache.mahout.math.function.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.
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.
Functions
public double aggregate(DoubleMatrix1D other, DoubleDoubleFunction aggr, DoubleDoubleFunction f)
Example:
org.apache.mahout.math.function.Functions F = org.apache.mahout.math.function.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.
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.
IllegalArgumentException
- if size() != other.size().Functions
public void assign(double[] values)
The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
values
- the values to be filled into the cells.
IllegalArgumentException
- if values.length != size().public void assign(double value)
value
- the value to be filled into the cells.public void assign(DoubleFunction function)
Example:
// change each cell to its sine matrix = 0.5 1.5 2.5 3.5 matrix.assign(Functions.sin); --> matrix == 0.479426 0.997495 0.598472 -0.350783For further examples, see the package doc.
function
- a function object taking as argument the current cell's value.Functions
public DoubleMatrix1D assign(DoubleMatrix1D other)
other
- the source matrix to copy from (may be identical to the receiver).
IllegalArgumentException
- if size() != other.size().public Vector toVector()
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, org.apache.mahout.math.function.Functions.pow); --> m1 == 1 1 16 729For further examples, see the package doc.
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
public void assign(DoubleMatrix1D y, DoubleDoubleFunction function, org.apache.mahout.math.list.IntArrayList nonZeroIndexes)
Example:
// assign x[i] = x[i]y[i] m1 = 0 1 2 3; m2 = 0 2 4 6; m1.assign(m2, org.apache.mahout.math.function.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.
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
public int cardinality()
protected int cardinality(int maxCardinality)
public DoubleMatrix1D copy()
Note that the returned matrix is an independent deep copy. The returned matrix is not backed by this matrix, so changes in the returned matrix are not reflected in this matrix, and vice-versa.
public boolean equals(double value)
value
- the value to test against.
public boolean equals(Object obj)
true
if and only if the argument is
not null
and is at least a DoubleMatrix1D
object that has the same sizes as the receiver
and has exactly the same values at the same indexes.
equals
in class Object
obj
- the object to compare with.
true
if the objects are the same; false
otherwise.public double get(int index)
index
- the index of the cell.
IndexOutOfBoundsException
- if index<0 || index>=size().protected DoubleMatrix1D getContent()
public void getNonZeros(org.apache.mahout.math.list.IntArrayList indexList, org.apache.mahout.math.list.DoubleArrayList valueList)
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).
Example:
0, 0, 8, 0, 7 --> indexList = (2,4) valueList = (8,7)In other words, get(2)==8, get(4)==7.
indexList
- the list to be filled with indexes, can have any size.valueList
- the list to be filled with values, can have any size.public void getNonZeros(org.apache.mahout.math.list.IntArrayList indexList, org.apache.mahout.math.list.DoubleArrayList valueList, int maxCardinality)
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).
Example:
0, 0, 8, 0, 7 --> indexList = (2,4) valueList = (8,7)In other words, get(2)==8, get(4)==7.
indexList
- the list to be filled with indexes, can have any size.valueList
- the list to be filled with values, can have any size.public abstract 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().
index
- the index of the cell.
protected boolean haveSharedCells(DoubleMatrix1D other)
protected boolean haveSharedCellsRaw(DoubleMatrix1D other)
public DoubleMatrix1D like()
public abstract DoubleMatrix1D like(int size)
size
- the number of cell the matrix shall have.
public abstract DoubleMatrix2D like2D(int rows, int columns)
rows
- the number of rows the matrix shall have.columns
- the number of columns the matrix shall have.
public void set(int index, double value)
index
- the index of the cell.value
- the value to be filled into the specified cell.
IndexOutOfBoundsException
- if index<0 || index>=size().public abstract 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().
index
- the index of the cell.value
- the value to be filled into the specified cell.public void swap(DoubleMatrix1D other)
IllegalArgumentException
- if size() != other.size().public double[] toArray()
public void toArray(double[] values)
IllegalArgumentException
- if values.length < size().protected DoubleMatrix1D view()
clone()
and casts the result. Note that the view is not a deep copy. The returned matrix is backed by this matrix, so changes in the returned matrix are reflected in this matrix, and vice-versa.
Use copy()
to
construct an independent deep copy rather than a new view.
public DoubleMatrix1D viewPart(int index, int width)
Note that the view is really just a range restriction: The returned matrix is backed by this matrix, so changes in the returned matrix are reflected in this matrix, and vice-versa.
The view contains the cells from index..index+width-1. and has view.size() == width. A view's legal coordinates are again zero based, as usual. In other words, legal coordinates of the view are 0 .. view.size()-1==width-1. As usual, any attempt to access a cell at other coordinates will throw an IndexOutOfBoundsException.
index
- The index of the first cell.width
- The width of the range.
IndexOutOfBoundsException
- if index<0 || width<0 || index+width>size().protected abstract DoubleMatrix1D viewSelectionLike(int[] offsets)
offsets
- the offsets of the visible elements.
public double zDotProduct(DoubleMatrix1D y)
y
- the second vector.
public double zDotProduct(DoubleMatrix1D y, int from, int length)
y
- the second vector.from
- the first index to be considered.length
- the number of cells to be considered.
public double zDotProduct(DoubleMatrix1D y, int from, int length, org.apache.mahout.math.list.IntArrayList nonZeroIndexes)
y
- the second vector.nonZeroIndexes
- the indexes of cells in yhaving a non-zero value.
protected double zDotProduct(DoubleMatrix1D y, org.apache.mahout.math.list.IntArrayList nonZeroIndexes)
y
- the second vector.nonZeroIndexes
- the indexes of cells in yhaving a non-zero value.
public double zSum()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |