public class VectorType extends GraphType implements AsciiComm
VectorType sets independentVariables = 1 and dependentVariables = 1 so it represents the values of a scalar function of one independent variable. If that variable is sampled uniformly, then the object holds only the sampled data and a Triplet indicating how the sampling is done. If the independent variable is sampled irregularly, then the object holds the sampling values as well. Users can use method isIndependentTriplet (or method isUniform) to see which case holds.
VectorType defines new methods that allow padding or interpolation of the data with zeros. These are useful in many signal-analysis applications that will use types derived from VectorType.
VectorType replaces the old Triana type RawData. For compatibility with that class there are some obsolete functions and parameters added here. In later releases these should be removed.
TrianaType
,
GraphType
,
Arithmetic
,
MatrixType
,
Triplet
,
Serialized FormModifier and Type | Field and Description |
---|---|
double[] |
x
(Parameter that is kept for consistency with previous versions, but which is obsolete.
|
java.lang.String |
xlabel
(Parameter that is kept for consistency with previous versions, but which is obsolete.
|
double[] |
y
(Parameter that is kept for consistency with previous versions, but which is obsolete.
|
java.lang.String |
ylabel
(Parameter that is kept for consistency with previous versions, but which is obsolete.
|
NOT_CONNECTED, NOT_READY, OUT_OF_RANGE
Constructor and Description |
---|
VectorType()
Creates a new empty VectorType, but it has to have specified dimensions.
|
VectorType(double[] y)
Creates a new real VectorType with a uniformly sampled independent variable by using the argument array of
doubles as the data and assuming that the independent variable is simply the index of the data array, ie it runs
from 0 to length - 1 in steps of 1.
|
VectorType(double[] x,
double[] y)
Creates a new real VectorType using the first argument array of doubles as the sampling values of the independent
variable and the second argument array of doubles as the real data.
|
VectorType(double[] xr,
double[] xi,
double[] yr,
double[] yi)
Creates a new complex-valued VectorType with a complex independent variable by using the first two argument
arrays of doubles as the real part and imaginary part of the indpendent variable, and the second two argument
arrays of doubles as the real part and imaginary part of the dependent variable.
|
VectorType(Triplet xTr,
double[] y)
Creates a new real VectorType with a uniformly sampled independent variable by using the first argument as the as
the Triplet that determines how the independent variable is uniformly sampled and the second argument as the real
data.
|
VectorType(Triplet xTr,
double[] yr,
double[] yi)
Creates a new complex-valued VectorType with a real uniformly-sampled independent variable by using the first
(Triplet) argument to determine how the independent variable is uniformly sampled, the second argument (double[])
as the real part of the data, and the third argument (double[]) as the imaginary part.
|
Modifier and Type | Method and Description |
---|---|
TrianaType |
copyMe()
This is one of the most important methods of Triana data.
|
void |
extendWithZeros(int newLength,
boolean front)
Extends the data set (both real and imaginary parts) to a longer set by padding with zeros.
|
double[] |
getData()
A synonym for getDataReal for use when data is known to be only real.
|
double[] |
getDataImag()
Returns the imaginary part of the data array for the dependent variable.
|
double[] |
getDataReal()
Returns the real part of the data array for the given dependent variable.
|
double[] |
getGraph()
A synonym for getGraphReal for use when the data is known to be real.
|
double[] |
getGraphImag()
Returns the imaginary part of the array that will be graphed for the given dependent variable.
|
double[] |
getGraphReal()
Returns the real part of the array that will be graphed for the given dependent variable.
|
double[] |
getScale()
A synonym for getScaleReal for use when the data are known to be real.
|
double[] |
getScaleImag()
Returns an array containing the imaginary part of the data scale for the independent variable.
|
double[] |
getScaleReal()
Returns an array containing the real part of the data scale for the independent variable.
|
double[] |
getXArray()
A synonym for getXReal for use when the data are known to be real.
|
double[] |
getXImag()
Returns the imaginary part of the data array for the independent variable.
|
double[] |
getXReal()
Returns the real part of the data array for the independent variable.
|
Triplet |
getXTriplet()
Returns the Triplet giving the independent data.
|
void |
initialiseData()
Sets the data array(s) to zero if they have been allocated.
|
void |
initialiseDataComplex(int len)
Allocates the real and imaginary parts of the data to double arrays of the given length and then sets their
elements to zero.
|
void |
initialiseDataReal(int len)
Allocates the real part of the data to a double array of the given length and then sets its elements to zero.
|
void |
interpolateZeros(int factor,
boolean before)
Inserts zeros in between existing elements of the data set.
|
boolean |
isCompatible(TrianaType obj)
Tests the argument object to determine if it makes sense to perform arithmetic operations between it and the
current object.
|
boolean |
isTriplet()
Tests to see if the independent variable is represented by a Triplet.
|
boolean |
isUniform()
Tests to see if the independent variable is uniformly sampled.
|
int |
length()
A synonym for size.
|
void |
setData(double[] data)
An alias for setDataReal, useful in derived classes where the data is assumed to be real all the time.
|
void |
setData(double[] dataReal,
double[] dataImag)
Sets the two argument double[] arrays as the real and imaginary parts of the dependent variable.
|
void |
setDataImag(double[] data)
Sets the argument double[] array as the imaginary part of the dependent variable.
|
void |
setDataReal(double[] data)
Sets the argument double[] array as the (real part of) the dependent variable.
|
void |
setX(double[] data)
Sets the argument double[] as the independent variable.
|
void |
setX(double[] xReal,
double[] xImag)
Sets the two argument double[] arrays as the real and imaginary parts of the independent variable.
|
void |
setX(Triplet tr)
Sets the argument Triplet as the independent variable.
|
void |
setXImag(double[] data)
Sets the argument double[] as the imaginary part of the independent variable.
|
void |
setXReal(double[] data)
Sets the argument double[] as the (real part of the) independent variable.
|
int |
size()
Returns the size or length of the data array.
|
boolean |
testDataModel()
Tests to make sure this Object obeys the VectorType data model.
|
protected void |
updateObsoletePointers() |
add, addToTitle, convertDependentDataArraysToBytes, convertDependentDataArraysToDoubles, convertDependentDataArraysToFloats, convertDependentDataArraysToInts, convertDependentDataArraysToLongs, convertDependentDataArraysToShorts, copyData, copyLabels, copyParameters, divide, equals, getDataArrayClass, getDataArrayImag, getDataArrayImag, getDataArrayImagAsBytes, getDataArrayImagAsDoubles, getDataArrayImagAsFloats, getDataArrayImagAsInts, getDataArrayImagAsLongs, getDataArrayImagAsShorts, getDataArrayReal, getDataArrayReal, getDataArrayRealAsBytes, getDataArrayRealAsDoubles, getDataArrayRealAsFloats, getDataArrayRealAsInts, getDataArrayRealAsLongs, getDataArrayRealAsShorts, getDataArrayTypeNames, getDependentLabels, getDependentVariableDimensions, getDependentVariables, getDimensionLengths, getDimensionLengths, getGraphArrayImag, getGraphArrayImagLog10, getGraphArrayReal, getGraphArrayRealLog10, getIndependentArrayImag, getIndependentArrayReal, getIndependentLabels, getIndependentScaleImag, getIndependentScaleImagLog10, getIndependentScaleReal, getIndependentScaleRealLog10, getIndependentTriplet, getIndependentVariables, getLabels, getLabelsColumn, getTitle, inputFromStream, isArithmeticArray, isArithmeticData, isCompatible, isDependentComplex, isIndependentComplex, isPrimitiveArray, isPrimitiveData, isTriplet, isUniform, maxDependentGraphingValuesImag, maxDependentGraphingValuesReal, maxDependentVariablesImag, maxDependentVariablesReal, maxIndependentScalesImag, maxIndependentScalesReal, maxIndependentVariablesImag, maxIndependentVariablesReal, minDependentGraphingValuesImag, minDependentGraphingValuesReal, minDependentVariablesImag, minDependentVariablesReal, minIndependentScalesImag, minIndependentScalesReal, minIndependentVariablesImag, minIndependentVariablesReal, multiply, outputToStream, resetDependent, resetIndependent, restrictToSubdomain, restrictToSubdomain, setDataArrayImag, setDataArrayReal, setDefaultAxisLabelling, setDependentLabels, setDependentVariableDimensions, setDimensionLengths, setDimensionLengths, setDimensions, setIndependentArrayImag, setIndependentArrayReal, setIndependentLabels, setIndependentTriplet, setIndependentTriplet, setLabels, setTitle, subtract
containerSize, dataExists, deleteFromContainer, getDataContainer, getFromContainer, getSequenceNumber, insertIntoContainer, inspectDataContainer, setDataContainer, setSequenceNumber
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
inputFromStream, outputToStream
public java.lang.String xlabel
The x-axis label. Now obsolete, replaced by GraphType.labels.
public java.lang.String ylabel
The y-axis label. Now obsolete, replaced by GraphType.labels.
public double[] x
The x data. Now obsolete, replaced by TrianaType.dataContainer.
public double[] y
The y data. Now obsolete, replaced by TrianaType.dataContainer.
public VectorType()
public VectorType(double[] y)
y
- Dependent data arraypublic VectorType(double[] x, double[] y)
x
- Independent data arrayy
- Dependent data arraypublic VectorType(Triplet xTr, double[] y)
One can invoke this method by constructing the Triplet argument in the reference statement to this Constructor, eg by using an argument of the form
new Triplet(length, start, step)
xTr
- the generator of the independent variabley
- the data of the dependent variableTriplet
public VectorType(Triplet xTr, double[] yr, double[] yi)
One can invoke this method by constructing the Triplet argument in the reference statement to this Constructor, eg by using an argument of the form
new Triplet(length, start, step)
xTr
- the generator of the independent variableyr
- the data of the real part of the dependent variableyi
- the data of the imaginary part of the dependent variableTriplet
public VectorType(double[] xr, double[] xi, double[] yr, double[] yi)
xr
- the real part of the data of the independent variablexi
- the imaginary part of the data of the independent variableyr
- the real part of the data of the dependent variableyi
- the imaginary part of the data of the dependent variablepublic boolean isUniform()
public boolean isTriplet()
Triplet
public int size()
public int length()
public double[] getDataReal()
public double[] getGraphReal()
GraphType
public double[] getDataImag()
public double[] getGraphImag()
GraphType
public double[] getData()
public double[] getGraph()
public void setDataReal(double[] data)
data
- The new datapublic void setData(double[] data)
data
- The new datapublic void setDataImag(double[] data)
data
- The new datapublic void setData(double[] dataReal, double[] dataImag)
dataReal
- The real part of the new datadataImag
- The imaginary part of the new datapublic void initialiseData()
public void initialiseDataReal(int len)
len
- The length of the data array being createdpublic void initialiseDataComplex(int len)
len
- The length of the data arrays being createdpublic Triplet getXTriplet()
Triplet
public double[] getXReal()
Triplet
public double[] getScaleReal()
GraphType
public double[] getXImag()
public double[] getScaleImag()
GraphType
public double[] getXArray()
public double[] getScale()
public void setX(Triplet tr)
tr
- The new dataTriplet
public void setX(double[] data)
data
- The new data for the independent variablepublic void setXReal(double[] data)
data
- The new data for the real part of the independent variablepublic void setXImag(double[] data)
data
- The new data for the imaginary part of the independent variablepublic void setX(double[] xReal, double[] xImag)
xReal
- The real part of the independent variablexImag
- The imaginary part of the independent variablepublic void extendWithZeros(int newLength, boolean front)
If the new length is shorter than the old, nothing is done.
Derived types should override this if necessary to provide for the correct handling of parameters and other special features.
newLength
- The new length of the data setfront
- True if padding is at the front, false for padding at the backpublic void interpolateZeros(int factor, boolean before)
If the argument factor is zero or negative, nothing is done.
Derived types should override this if necessary to provide for the correct handling of parameters and other special features.
factor
- The number of zeros per data point to be insertedbefore
- True if the zeros go before each point, false if afterpublic boolean testDataModel()
testDataModel
in class GraphType
Triplet
public TrianaType copyMe()
To override, the programmer should not invoke the super.copyMe method. Instead, create an object of the current type and call methods copyData and copyParameters. If these have been written correctly, then they will do the copying. The code should createTool, for type YourType:
YourType y = null; try { y = (YourType)getClass().newInstance(); y.copyData( this ); y.copyParameters( this ); y.setLegend( this.getLegend() ); } catch (IllegalAccessException ee) { System.out.println("Illegal Access: " + ee.getMessage()); } catch (InstantiationException ee) { System.out.println("Couldn't be instantiated: " + ee.getMessage()); } return y;
The copied object's data should be identical to the original. The method here modifies only one item: a String indicating that the object was created as a copy is added to the description StringVector.
public boolean isCompatible(TrianaType obj)
In VectorType, this method tests first for compatibility with superior classes and then tests whether the input is a VectorType data object with the same value of isUniform as the current one. It does not require that the independent data values should be the same, since one might want to add together subsequent data sets, e.g. when one performs averages.
Classes derived from this should over-ride this method with further tests as appropriate. The over-riding method should normally have the first lines
boolean test = super.isCompatible( obj );followed by other tests. If other types not subclassed from GraphType or Const should be allowed to be compatible then other tests must be implemented.
obj
- The data object to be compared with the current oneprotected void updateObsoletePointers()
updateObsoletePointers
in class TrianaType