org.apache.mahout.math
Class ConstantVector

java.lang.Object
  extended by org.apache.mahout.math.AbstractVector
      extended by org.apache.mahout.math.ConstantVector
All Implemented Interfaces:
Cloneable, Iterable<Vector.Element>, Vector

public class ConstantVector
extends AbstractVector

Implements a vector with all the same values.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.mahout.math.AbstractVector
AbstractVector.LocalElement
 
Nested classes/interfaces inherited from interface org.apache.mahout.math.Vector
Vector.Element
 
Field Summary
 
Fields inherited from class org.apache.mahout.math.AbstractVector
lengthSquared
 
Constructor Summary
ConstantVector(double value, int size)
           
 
Method Summary
 int getNumNondefaultElements()
          Return the number of values in the recipient
 double getQuick(int index)
          Return the value at the given index, without checking bounds
 boolean isDense()
           
 boolean isSequentialAccess()
           
 Iterator<Vector.Element> iterateNonZero()
          Iterates over all non-zero elements.
 Iterator<Vector.Element> iterator()
          Iterates over all elements

* NOTE: Implementations may choose to reuse the Element returned for performance reasons, so if you need a copy of it, you should call AbstractVector.getElement(int) for the given index

 Vector like()
          Return an empty vector of the same underlying class as the receiver
protected  Matrix matrixLike(int rows, int columns)
          Subclasses must override to return an appropriately sparse or dense result
 void setQuick(int index, double value)
          Set the value at the given index, without checking bounds
 
Methods inherited from class org.apache.mahout.math.AbstractVector
aggregate, aggregate, asFormatString, assign, assign, assign, assign, assign, assign, clone, cross, divide, dot, dotSelf, equals, get, getDistanceSquared, getElement, getLengthSquared, hashCode, logNormalize, logNormalize, logNormalize, maxValue, maxValueIndex, minus, minValue, minValueIndex, norm, normalize, normalize, plus, plus, set, size, times, times, toString, toString, viewPart, zSum
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantVector

public ConstantVector(double value,
                      int size)
Method Detail

matrixLike

protected Matrix matrixLike(int rows,
                            int columns)
Subclasses must override to return an appropriately sparse or dense result

Specified by:
matrixLike in class AbstractVector
Parameters:
rows - the row cardinality
columns - the column cardinality
Returns:
a Matrix

isDense

public boolean isDense()
Returns:
true iff this implementation should be considered dense -- that it explicitly represents every value

isSequentialAccess

public boolean isSequentialAccess()
Returns:
true iff this implementation should be considered to be iterable in index order in an efficient way. In particular this implies that iterator() and iterateNonZero() return elements in ascending order by index.

iterator

public Iterator<Vector.Element> iterator()
Iterates over all elements

* NOTE: Implementations may choose to reuse the Element returned for performance reasons, so if you need a copy of it, you should call AbstractVector.getElement(int) for the given index

Returns:
An Iterator over all elements

iterateNonZero

public Iterator<Vector.Element> iterateNonZero()
Iterates over all non-zero elements.

NOTE: Implementations may choose to reuse the Element returned for performance reasons, so if you need a copy of it, you should call AbstractVector.getElement(int) for the given index

Returns:
An Iterator over all non-zero elements

getQuick

public double getQuick(int index)
Return the value at the given index, without checking bounds

Parameters:
index - an int index
Returns:
the double at the index

like

public Vector like()
Return an empty vector of the same underlying class as the receiver

Returns:
a Vector

setQuick

public void setQuick(int index,
                     double value)
Set the value at the given index, without checking bounds

Parameters:
index - an int index into the receiver
value - a double value to set

getNumNondefaultElements

public int getNumNondefaultElements()
Return the number of values in the recipient

Returns:
an int


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.