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 |
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 |
getLast()
Returns the last knot in this list.
|
void |
getMinMaxValues(double[] minMax) |
int |
getNumKnots()
Returns the number of knots in this list.
|
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 |
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 |
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 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 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 int getNumKnots()
public boolean isEmpty()
public void clear()
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() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
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
.