public class DoubleFV extends ArrayFeatureVector<double[]> implements Concatenatable<DoubleFV,DoubleFV>, Cloneable
values
Constructor and Description |
---|
DoubleFV()
Construct an empty feature vector
|
DoubleFV(double[] values)
Construct from flattened values array and dimensions
|
DoubleFV(int nbins)
Construct empty FV with given number of bins
|
Modifier and Type | Method and Description |
---|---|
String |
asciiHeader()
Header for ascii input.
|
DoubleFV |
asDoubleFV()
Convert the FV to a DoubleFV representation
|
double[] |
asDoubleVector()
Convert the FV to a 1-dimensional double array representation
|
byte[] |
binaryHeader()
Header for binary input.
|
DoubleFV |
clone() |
double |
compare(DoubleFV h,
DoubleFVComparison method)
Compare this FV to another with the given method.
|
DoubleFV |
concatenate(DoubleFV... ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
DoubleFV |
concatenate(List<DoubleFV> ins)
Concatenate all the inputs with this, returning a new object that is the
result of the concatenation.
|
boolean |
equals(Object obj) |
double |
get(int x)
Get the element at the given flat index
|
double |
getAsDouble(int i)
Get an element of the feature as a double value
|
int |
hashCode() |
int |
length()
Get the length of this vector
|
DoubleFV |
newInstance()
Construct a new instance of this featurevector.
|
DoubleFV |
normaliseFV()
Normalise the FV to unit area.
|
DoubleFV |
normaliseFV(double p)
Lp Norm of the FV.
|
DoubleFV |
normaliseFV(double[] min,
double[] max)
Element-wise normalisation to 0..1 using separated expected
minimum and maximum values for each element of the underlying
feature vector.
|
DoubleFV |
normaliseFV(double min,
double max)
Min-Max normalisation of the FV.
|
void |
readASCII(Scanner in)
Read internal state from in.
|
void |
readBinary(DataInput in)
Read internal state from in.
|
void |
setFromDouble(int i,
double v)
Set an element of the feature from a double value
|
DoubleFV |
subvector(int beginIndex)
Returns a new featurevector that is a subsequence of this vector.
|
DoubleFV |
subvector(int beginIndex,
int endIndex)
Returns a new string that is a subvector of this vector.
|
String |
toString() |
void |
writeASCII(PrintWriter out)
Write the content of this as ascii to out.
|
void |
writeBinary(DataOutput out)
Write the content of this as binary to out.
|
getVector
public DoubleFV()
public DoubleFV(int nbins)
nbins
- the number of bins in each dimensionpublic DoubleFV(double[] values)
values
- the flat array of valuespublic double get(int x)
x
- the flattened element indexpublic DoubleFV normaliseFV(double[] min, double[] max)
normaliseFV
in interface FeatureVector
min
- an array containing the minimum expected valuesmax
- an array containing the maximum expected valuespublic DoubleFV normaliseFV(double min, double max)
normaliseFV
in interface FeatureVector
min
- the minimum expected valuemax
- the maximum expected valuepublic DoubleFV normaliseFV()
normaliseFV
in interface FeatureVector
public DoubleFV normaliseFV(double p)
normaliseFV
in interface FeatureVector
p
- the norm to computepublic DoubleFV asDoubleFV()
asDoubleFV
in interface FeatureVector
public double[] asDoubleVector()
asDoubleVector
in interface FeatureVector
public double compare(DoubleFV h, DoubleFVComparison method)
h
- the feature to compare against.method
- the method to compare with.public int length()
FeatureVector
length
in interface FeatureVector
public void writeBinary(DataOutput out) throws IOException
WriteableBinary
writeBinary
in interface WriteableBinary
out
- sink to write toIOException
- an error writing to outpublic void writeASCII(PrintWriter out) throws IOException
WriteableASCII
writeASCII
in interface WriteableASCII
out
- sink to write toIOException
- an error writing to outpublic void readBinary(DataInput in) throws IOException
ReadableBinary
readBinary
in interface ReadableBinary
in
- source to read from.IOException
- an error reading inputpublic void readASCII(Scanner in) throws IOException
ReadableASCII
readASCII
in interface ReadableASCII
in
- source to read from.IOException
- an error reading inputpublic byte[] binaryHeader()
ReadableBinary
binaryHeader
in interface ReadableBinary
binaryHeader
in interface WriteableBinary
public String asciiHeader()
ReadableASCII
asciiHeader
in interface ReadableASCII
asciiHeader
in interface WriteableASCII
public DoubleFV concatenate(DoubleFV... ins)
Concatenatable
concatenate
in interface Concatenatable<DoubleFV,DoubleFV>
ins
- the inputspublic DoubleFV concatenate(List<DoubleFV> ins)
Concatenatable
concatenate
in interface Concatenatable<DoubleFV,DoubleFV>
ins
- the inputspublic DoubleFV subvector(int beginIndex)
ArrayFeatureVector
subvector
in class ArrayFeatureVector<double[]>
beginIndex
- the beginning index, inclusive.public DoubleFV subvector(int beginIndex, int endIndex)
ArrayFeatureVector
beginIndex
and extends to the
element at index endIndex - 1
. Thus the length of the
subvector is endIndex-beginIndex
.subvector
in class ArrayFeatureVector<double[]>
beginIndex
- the beginning index, inclusive.endIndex
- the ending index, exclusive.public double getAsDouble(int i)
FeatureVector
getAsDouble
in interface FeatureVector
i
- the element indexpublic void setFromDouble(int i, double v)
FeatureVector
setFromDouble
in interface FeatureVector
i
- the element indexv
- the valuepublic DoubleFV newInstance()
FeatureVector
newInstance
in interface FeatureVector