public class DenseVector extends Object implements Vector
| Constructor and Description |
|---|
DenseVector()
Empty constructor necessary for making
RepresentationFactory
support this implementation. |
DenseVector(org.ejml.data.DenseMatrix64F featureVector)
Initializing constructor.
|
DenseVector(double[] featureVector)
Initializing constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(float coeff,
float vectorCoeff,
Vector vector)
Add a
vector multiplied by vectorCoeff to this
vector multiplied by |
void |
add(float coeff,
Vector vector)
Add a
vector multiplied by coeff to this vector |
void |
add(Vector vector)
Add a
vector to this vector |
DenseVector |
copyVector()
Returns a copy of this vector.
|
void |
diff(DenseVector vector) |
boolean |
equals(Object featureVector) |
float |
euclideanDistance(Vector vector)
Returns the euclidean distance between this vector and
vector |
Map<Object,Number> |
getActiveFeatures()
Returns a map containing all the non-zero features
|
double |
getFeatureValue(int featureIndex)
Returns the feature value of the
featureIndex-th element |
float |
getFeatureValue(Object featureIdentifier)
Returns the value of the feature identified with
featureIdentifier |
org.ejml.data.DenseMatrix64F |
getFeatureValues()
Returns the feature values in the EJML format
|
int |
getNumberOfFeatures()
Returns the number of featuresValues
|
float |
getSquaredNorm()
Returns the squared norm of this vector
|
String |
getTextFromData()
Returns a textual representation of the data stored in this
representation
|
DenseVector |
getZeroVector()
Returns a vector whose values are all 0.
|
float |
innerProduct(Vector vector)
Returns the dot product between this vector and
vector |
boolean |
isCompatible(Representation rep)
Evaluates whether a representation is compatible with this one, e.g.., they have
same type and pass additional checks that are type-dependent
|
void |
normalize()
Scales the representation in order to have a unit norm in the explicit feature
space
|
void |
pointWiseProduct(Vector vector)
Compute the point-wise product of this vector with the one in
vector. |
void |
scale(float coeff)
Multiplies each element of this representation by
coeff |
void |
setDataFromText(String representationDescription)
Set the values of the vectors according to the input text, which is expected to be
a sequence of numbers separated by a white space, or a comma, or a semicolon
|
void |
setFeatureValue(Object featureIdentifier,
float value)
Assigns
value to the feature identified by |
void |
setFeatureValues(org.ejml.data.DenseMatrix64F featureVector)
Sets the feature values.
|
void |
setFeatureValues(double[] featureValues)
Sets the feature values.
|
String |
toString() |
public static final String SEPARATOR
public DenseVector()
RepresentationFactory
support this implementation.featureVector - is an array of feature valuespublic DenseVector(double[] featureVector)
featureVector - is an array of feature valuespublic DenseVector(org.ejml.data.DenseMatrix64F featureVector)
featureVector - is an array of feature values in the EJML formatpublic void setDataFromText(String representationDescription)
setDataFromText in interface RepresentationrepresentationDescription - the textual descriptionpublic void setFeatureValues(double[] featureValues)
featureValues - is an array of feature valuespublic void setFeatureValues(org.ejml.data.DenseMatrix64F featureVector)
featureVector - is an array of feature values in the EJML formatpublic org.ejml.data.DenseMatrix64F getFeatureValues()
public double getFeatureValue(int featureIndex)
featureIndex-th elementfeatureIndex - the index of the feature whose value must be returnedpublic int getNumberOfFeatures()
public void normalize()
Normalizablenormalize in interface Normalizablepublic float innerProduct(Vector vector)
VectorvectorinnerProduct in interface Vectorpublic void pointWiseProduct(Vector vector)
Vectorvector.pointWiseProduct in interface Vectorvector - the vector used for the point-wise productpublic void scale(float coeff)
Normalizablecoeffscale in interface Normalizablecoeff - the scaling factorpublic void add(Vector vector)
Vectorvector to this vectorpublic void diff(DenseVector vector)
public void add(float coeff,
Vector vector)
Vectorvector multiplied by coeff to this vectorpublic float euclideanDistance(Vector vector) throws VectorOperationException
VectorvectoreuclideanDistance in interface VectorVectorOperationExceptionpublic void add(float coeff,
float vectorCoeff,
Vector vector)
Vectorvector multiplied by vectorCoeff to this
vector multiplied bypublic DenseVector getZeroVector()
VectorgetZeroVector in interface Vectorpublic String getTextFromData()
RepresentationgetTextFromData in interface Representationpublic float getSquaredNorm()
NormalizablegetSquaredNorm in interface Normalizablepublic Map<Object,Number> getActiveFeatures()
VectorgetActiveFeatures in interface Vectorpublic DenseVector copyVector()
VectorcopyVector in interface Vectorpublic void setFeatureValue(Object featureIdentifier, float value)
Vectorvalue to the feature identified by featureIdentifier
NOTE: this method could be not the most efficient to set a feature value. Actual implementations
of the Vector class may provide faster methods using their specific type to identify features (instead of
a generic Object)
setFeatureValue in interface VectorfeatureIdentifier - the identifier of the featurevalue - the value of the featurepublic float getFeatureValue(Object featureIdentifier)
VectorfeatureIdentifier
NOTE: this method could be not the most efficient to get a feature value. Actual implementations of the Vector class may provide faster methods using their specific type to identify features (instead of a generic Object)
getFeatureValue in interface Vectorpublic boolean isCompatible(Representation rep)
RepresentationisCompatible in interface Representationrep - the representation to be compared with this oneCopyright © 2018 Semantic Analytics Group @ Uniroma2. All rights reserved.