public class NumericList extends java.lang.Object implements java.lang.Cloneable, java.lang.Iterable<NumericListKnot>, Scannable
Constructor and Description |
---|
NumericList(int vsize)
Creates an empty numeric list for holding vectors of a prescribed size.
|
Modifier and Type | Method and Description |
---|---|
NumericListKnot |
add(NumericListKnot knot)
Adds a knot into this numeric list.
|
NumericListKnot |
add(NumericListKnot knot,
NumericListKnot last) |
NumericListKnot |
add(Vector vals,
double t)
Creates a knot with the specified values and time and adds it into this
numeric list.
|
void |
applyMovingAverageSmoothing(int winSize)
Smooths the values in this list by applying a mean average filter over a
moving window of specified size.
|
void |
applySavitzkyGolaySmoothing(int winSize,
int deg)
Smooths the values in this list by applying Savitzky-Golay smoothing over
a moving window of specified size.
|
void |
clear()
Removes all knots in the numeric list.
|
void |
clearAfter(NumericListKnot knot)
Removes all knots after a specific knot in this list.
|
java.lang.Object |
clone()
Returns a deep copy of this numeric list.
|
boolean |
equals(NumericList list)
Returns true if the contents of this numeric list equal the contents of
another numeric list.
|
NumericListKnot |
findKnotAtOrBefore(double t,
NumericListKnot last)
Finds the knot whose t value is closest to, and if possible less or equal
to, a specified value.
|
NumericListKnot |
findKnotClosest(double t)
Finds the knot whose t value is closest to a specified value.
|
NumericListKnot |
findKnotClosest(double t,
NumericListKnot last) |
NumericListKnot |
getFirst()
Returns the first knot in this list.
|
Interpolation |
getInterpolation()
Returns the interpolation method for this list.
|
NumericListKnot |
getKnot(int idx)
Returns the idx-th knot in this list, or
null if so such
knot exists; |
NumericListKnot |
getLast()
Returns the last knot in this list.
|
void |
getMinMaxValues(double[] minMax) |
void |
getMinMaxValues(VectorNd min,
VectorNd max)
Queries the minimum and maximun values of each vector
element over all the knots.
|
int |
getNumKnots()
Returns the number of knots in this list.
|
void |
getSumSquaredValues(VectorNd sumsqr)
Returns the sum of the square of each vector element over all the knots.
|
double[][] |
getValues()
Returns the values of this numeric list as a two dimensional array of
doubles.
|
int |
getVectorSize()
Returns the size of the vectors associated with this list.
|
void |
interpolate(VectorNd v,
double t)
Interpolates the value associated with a particular value of t, based on
the current contents of this list.
|
NumericListKnot |
interpolate(VectorNd v,
double t,
Interpolation.Order order,
boolean extendData,
NumericListKnot last) |
NumericListKnot |
interpolate(VectorNd v,
double t,
Interpolation method,
NumericListKnot last) |
void |
interpolateCubic(VectorNd v,
NumericListKnot prev,
double t) |
boolean |
isEmpty()
Returns true if this list is empty.
|
boolean |
isWritable()
Returns
true if this component should in fact be written to
secondary storage. |
java.util.Iterator<NumericListKnot> |
iterator()
Returns an iterator over all the knots in this numeric list.
|
NumericListKnot |
remove(double t)
Removes and return the knot at time t, if any.
|
void |
remove(NumericListKnot knot)
Removes a knot from this numeric list.
|
void |
scale(double s)
Uniformly scales all the values in this list
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setInterpolation(Interpolation method)
Sets the interpolation method for this list.
|
void |
setInterpolationOrder(Interpolation.Order order)
Sets the interpolation order for this list.
|
void |
setValues(double[][] vals)
Sets the values of this numeric list from a two dimensional array of
doubles.
|
void |
shiftTime(double t) |
java.lang.String |
toString()
Returns a string representation of this numeric list.
|
java.lang.String |
toString(NumberFormat fmt)
Returns a String representation of this numeric list, in which each
element is formatted using a C
printf style as decribed by
the parameter NumberFormat . |
java.lang.String |
toString(java.lang.String fmtStr)
Returns a String representation of this numeric list, in which each
element is formatted using a C
printf style format string. |
java.lang.String |
toStringSuper() |
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter.
|
public NumericList(int vsize)
vsize
- size of the vectors that will form this listpublic void setInterpolation(Interpolation method)
Step
with no end data extension.method
- new interpolation method.public void setInterpolationOrder(Interpolation.Order order)
Step
.order
- new interpolation order;public Interpolation getInterpolation()
setInterpolation(maspack.interpolation.Interpolation)
public int getVectorSize()
public NumericListKnot add(NumericListKnot knot)
knot
- knot to add to the listjava.lang.IllegalArgumentException
- if the knot's vector has a size not equal to the vector size for this
list.getVectorSize()
public NumericListKnot add(Vector vals, double t)
vals
- values for the knott
- time at which the knot should be addedjava.lang.IllegalArgumentException
- if values
has a size less than the vector size for this
list.getVectorSize()
public NumericListKnot add(NumericListKnot knot, NumericListKnot last)
public void shiftTime(double t)
public void getMinMaxValues(double[] minMax)
public void getSumSquaredValues(VectorNd sumsqr)
sumsqr
- returns the mean square valuespublic void getMinMaxValues(VectorNd min, VectorNd max)
min
- returns the minimum valuesmax
- returns the maximum valuespublic NumericListKnot remove(double t)
t
- time of the knot to removepublic void remove(NumericListKnot knot)
knot
- knot to removepublic void clearAfter(NumericListKnot knot)
knot
- all knots following this one will be removedpublic NumericListKnot findKnotAtOrBefore(double t, NumericListKnot last)
t
- specified valuepublic NumericListKnot findKnotClosest(double t)
t
- specified valuepublic NumericListKnot findKnotClosest(double t, NumericListKnot last)
public void interpolate(VectorNd v, double t)
v
- stores the interpolation resultt
- value to interpolate forImproperStateException
- if the list is emptypublic void interpolateCubic(VectorNd v, NumericListKnot prev, double t)
public NumericListKnot interpolate(VectorNd v, double t, Interpolation method, NumericListKnot last)
public NumericListKnot interpolate(VectorNd v, double t, Interpolation.Order order, boolean extendData, NumericListKnot last)
public NumericListKnot getFirst()
public NumericListKnot getLast()
public NumericListKnot getKnot(int idx)
null
if so such
knot exists;public int getNumKnots()
public boolean isEmpty()
public void clear()
public void scale(double s)
s
- scale factorpublic void applyMovingAverageSmoothing(int winSize)
winSize
- size of the averaging window. The value should be odd; if
it is even, it will be incremented internally to be odd. The method does
nothing if the value is is less than 1. Finally, winSize
will be
reduced if necessary to fit the number of knots.public void applySavitzkyGolaySmoothing(int winSize, int deg)
deg
, and then using this to recompute the value in the middle of the
window. The polynomial is also used to interpolate the first and last
winSize/2
values, since it is not possible to center the window
on these.deg
- degree of the smoothing polynomial. Must be at least 1.winSize
- size of the averaging window. The value must be >=
deg+1
and should also be odd; if it is even, it will be incremented
internally to be odd. Finally, winSize
will be reduced if
necessary to fit the number of knots.public java.util.Iterator<NumericListKnot> iterator()
iterator
in interface java.lang.Iterable<NumericListKnot>
public double[][] getValues()
public void setValues(double[][] vals)
getValues()
.vals
- Values used to set this numeric listpublic boolean equals(NumericList list)
list
- numeric list to compare withpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String fmtStr)
printf
style format string.
For a description of the format string syntax, see NumberFormat
.fmtStr
- numeric format specificationpublic java.lang.String toString(NumberFormat fmt)
printf
style as decribed by
the parameter NumberFormat
. When called numerous times,
this routine can be more efficient than toString(String)
, because the NumberFormat
does not need to be recreated each time from a specification
string.fmt
- numeric formatpublic java.lang.String toStringSuper()
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean isWritable()
true
if this component should in fact be written to
secondary storage. This gives subclasses control over whether or
not they are actually written out.isWritable
in interface Scannable
true
if this component should be written to
secondary storage.public void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
scan
and complete
enough to allow full reconstruction of the element.public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
write
.