visad
Class SingletonSet

java.lang.Object
  extended by visad.ThingImpl
      extended by visad.DataImpl
          extended by visad.Set
              extended by visad.SimpleSet
                  extended by visad.SampledSet
                      extended by visad.SingletonSet
All Implemented Interfaces:
Serializable, Cloneable, Data, SampledSetIface, SetIface, SimpleSetIface, Thing

public class SingletonSet
extends SampledSet

SingletonSet is the class for Set-s containing one member.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class visad.DataImpl
DataImpl.Syncher
 
Field Summary
 
Fields inherited from interface visad.Data
ABS, ACOS, ACOS_DEGREES, ADD, ASIN, ASIN_DEGREES, ATAN, ATAN_DEGREES, ATAN2, ATAN2_DEGREES, CEIL, COS, COS_DEGREES, DEGREES_TO_RADIANS, DEPENDENT, DIVIDE, EXP, FLOOR, INDEPENDENT, INV_ATAN2, INV_ATAN2_DEGREES, INV_DIVIDE, INV_POW, INV_REMAINDER, INV_SUBTRACT, LOG, MAX, MIN, MULTIPLY, NEAREST_NEIGHBOR, NEGATE, NO_ERRORS, NOP, POW, RADIANS_TO_DEGREES, REMAINDER, RINT, ROUND, SIN, SIN_DEGREES, SQRT, SUBTRACT, TAN, TAN_DEGREES, WEIGHTED_AVERAGE
 
Constructor Summary
SingletonSet(RealTuple d)
          Construct a SingletonSet with the single sample given by a RealTuple
SingletonSet(RealTuple d, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors)
          Construct a SingletonSet with the single sample given by a RealTuple, and a non-default CoordinateSystem, Units and ErrorEstimates.
SingletonSet(RealTupleType type, double[] values, CoordinateSystem coordSys, Unit[] units, ErrorEstimate[] errors)
          Constructs from a type, numeric values, units, coordinate system, and error estimates.
 
Method Summary
 Object cloneButType(MathType type)
          Clone this SingletonSet, but change the MathType
 int[] doubleToIndex(double[][] value)
          convert an array of doubles in R^DomainDimension to an array of 1-D indices
 void doubleToInterp(double[][] value, int[][] indices, double[][] weights)
          for each of an array of values in R^DomainDimension, compute an array of 1-D indices and an array of weights, to be used for interpolation; indices[i] and weights[i] are null if i-th value is outside grid (i.e., if no interpolation is possible)
 boolean equals(Object set)
          See if this SingletonSet is equal to the Object in question.
 RealTuple getData()
          Get the RealTuple that this SingletonSet was initialized with.
 double[][] getDoubles(boolean copy)
          Get the values from the RealTuple as an array of doubles
 void getNeighbors(int[][] neighbors)
          Returns an array of indexes for neighboring points for each point in the set.
 int hashCode()
          Returns the hash code of this instance.
 double[][] indexToDouble(int[] index)
          convert an array of 1-D indices to an array of doubles in R^DomainDimension
 float[][] indexToValue(int[] index)
          convert an array of 1-D indices to an array of values in R^DomainDimension
 boolean isMissing()
          Check if the samples are missing.
 String longString(String pre)
          Create string representation of this Set with a given prefix
 int[] valueToIndex(float[][] value)
          convert an array of values in R^DomainDimension to an array of 1-D indices
 void valueToInterp(float[][] value, int[][] indices, float[][] weights)
          for each of an array of values in R^DomainDimension, compute an array of 1-D indices and an array of weights, to be used for interpolation; indices[i] and weights[i] are null if i-th value is outside grid (i.e., if no interpolation is possible)
 
Methods inherited from class visad.SampledSet
clone, computeRanges, computeRanges, cram_missing, finalize, getHi, getLow, getMySamples, getNeighbors, getSamples, getSamples, make1DGeometry, make3DGeometry, makePointGeometry, setCacheSizeThreshold, setGeometryArray, setGeometryArray, setMySamples
 
Methods inherited from class visad.SimpleSet
getManifoldDimension
 
Methods inherited from class visad.Set
__getitem__, __len__, addEqualsCache, addNotEqualsCache, copyDoubles, copyFloats, doubleToFloat, equalUnitAndCS, floatToDouble, getCoordinateSystem, getDimension, getDoubles, getLength, getNeighbors, getSetErrors, getSetUnits, getWedge, longString, main, make2DGeometry, makeIsoLines, makeIsoSurface, makeSpatial, merge1DSets, testEqualsCache, testNotEqualsCache, unary, unitAndCSHashCode
 
Methods inherited from class visad.DataImpl
__add__, __add__, __div__, __div__, __mod__, __mod__, __mul__, __mul__, __neg__, __pow__, __pow__, __radd__, __rdiv__, __rmod__, __rmul__, __rpow__, __rsub__, __sub__, __sub__, abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, adjustSamplingError, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, max, max, min, min, multiply, multiply, negate, negate, notifyReferences, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, toString, unary
 
Methods inherited from class visad.ThingImpl
addReference, removeReference
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface visad.SetIface
equalUnitAndCS, getCoordinateSystem, getDimension, getDoubles, getLength, getManifoldDimension, getNeighbors, getSetErrors, getSetUnits, getWedge, make2DGeometry, makeIsoLines, makeIsoSurface, makeSpatial, merge1DSets
 
Methods inherited from interface visad.Data
abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, adjustSamplingError, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary, unary
 
Methods inherited from interface visad.Thing
addReference, removeReference
 

Constructor Detail

SingletonSet

public SingletonSet(RealTuple d)
             throws VisADException,
                    RemoteException
Construct a SingletonSet with the single sample given by a RealTuple

Parameters:
d - sample as a RealTuple
Throws:
VisADException - Couldn't create the necessary VisAD object
RemoteException - Couldn't create the necessary remote object

SingletonSet

public SingletonSet(RealTuple d,
                    CoordinateSystem coord_sys,
                    Unit[] units,
                    ErrorEstimate[] errors)
             throws VisADException,
                    RemoteException
Construct a SingletonSet with the single sample given by a RealTuple, and a non-default CoordinateSystem, Units and ErrorEstimates.

Parameters:
d - sample as a RealTuple
coord_sys - CoordinateSystem
units - Units
errors - ErrorEstimate
Throws:
VisADException - Couldn't create the necessary VisAD object
RemoteException - Couldn't create the necessary remote object

SingletonSet

public SingletonSet(RealTupleType type,
                    double[] values,
                    CoordinateSystem coordSys,
                    Unit[] units,
                    ErrorEstimate[] errors)
             throws VisADException,
                    RemoteException
Constructs from a type, numeric values, units, coordinate system, and error estimates.

Parameters:
type - The type for this instance.
values - The numeric values in units of the units argument (if non-null); otherwise, in units of the coordinate system argument (if non- null); otherwise, in the default units of the type argument.
coordSys - The coordinate system transformation for this instance or null.
units - The units of the numeric values or null.
errors - Error estimates for the values or null.
Throws:
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.
NullPointerException - if the type or values argument is null.
See Also:
CoordinateSystem.getCoordinateSystemUnits()
Method Detail

isMissing

public boolean isMissing()
Check if the samples are missing.

Specified by:
isMissing in interface Data
Overrides:
isMissing in class SampledSet
Returns:
false by definition, a SingletonSet never has missing samples since it is initialized with a RealTuple..

getNeighbors

public void getNeighbors(int[][] neighbors)

Returns an array of indexes for neighboring points for each point in the set. If neighbors is the return value, then neighbors[i][j] is the index of the jth neighbor of sample i.

This implementation places an array of length zero into the single element of the input array. The length is zero because instances of this class have no neighboring sample points.

Specified by:
getNeighbors in interface SetIface
Overrides:
getNeighbors in class Set
Parameters:
neighbors - The array to hold the indicial arrays for each sample point.
Throws:
ArrayIndexOutOfBoundsException - if the length of the argument array is zero.

indexToValue

public float[][] indexToValue(int[] index)
                       throws VisADException
convert an array of 1-D indices to an array of values in R^DomainDimension

Specified by:
indexToValue in interface SetIface
Specified by:
indexToValue in class Set
Parameters:
index - array of integer indices
Returns:
float array of values
Throws:
VisADException - couldn't create the necessary VisAD object

indexToDouble

public double[][] indexToDouble(int[] index)
                         throws VisADException
convert an array of 1-D indices to an array of doubles in R^DomainDimension

Specified by:
indexToDouble in interface SetIface
Overrides:
indexToDouble in class Set
Parameters:
index - The indicies of the sample points.
Returns:
double array of values
Throws:
VisADException - couldn't create the necessary VisAD object

valueToIndex

public int[] valueToIndex(float[][] value)
                   throws VisADException
convert an array of values in R^DomainDimension to an array of 1-D indices

Specified by:
valueToIndex in interface SetIface
Specified by:
valueToIndex in class Set
Parameters:
value - float[domain_dimension][number_of_values] array of Set values
Returns:
indices
Throws:
VisADException - couldn't create the necessary VisAD object

doubleToIndex

public int[] doubleToIndex(double[][] value)
                    throws VisADException
convert an array of doubles in R^DomainDimension to an array of 1-D indices

Specified by:
doubleToIndex in interface SetIface
Overrides:
doubleToIndex in class Set
Returns:
indices
Throws:
VisADException - couldn't create the necessary VisAD object

valueToInterp

public void valueToInterp(float[][] value,
                          int[][] indices,
                          float[][] weights)
                   throws VisADException
for each of an array of values in R^DomainDimension, compute an array of 1-D indices and an array of weights, to be used for interpolation; indices[i] and weights[i] are null if i-th value is outside grid (i.e., if no interpolation is possible)

Specified by:
valueToInterp in interface SimpleSetIface
Specified by:
valueToInterp in class SimpleSet
Parameters:
value - An array of points. value[i][j] is the i-th coordinate of the j-th points.
indices - Indices of the neighboring samples in the set. If the j-th points lies within the set, then returned element [i][j] is the index of the i-th neighboring sample in the set; otherwise, returned array [j] is null.
weights - Weights for interpolating the neighboring samples in the set. If the j-th points lies within the set, then returned element [i][j] is the weight of the i-th neighboring sample in the set; otherwise, returned array [j] is null.
Throws:
VisADException - VisAD failure.

doubleToInterp

public void doubleToInterp(double[][] value,
                           int[][] indices,
                           double[][] weights)
                    throws VisADException
for each of an array of values in R^DomainDimension, compute an array of 1-D indices and an array of weights, to be used for interpolation; indices[i] and weights[i] are null if i-th value is outside grid (i.e., if no interpolation is possible)

Throws:
VisADException

getDoubles

public double[][] getDoubles(boolean copy)
                      throws VisADException
Get the values from the RealTuple as an array of doubles

Specified by:
getDoubles in interface SetIface
Overrides:
getDoubles in class Set
Parameters:
copy - Whether or not to make a copy of the samples of the set.
Returns:
samples as doubles.
Throws:
VisADException - couldn't create the necessary VisAD object

getData

public RealTuple getData()
Get the RealTuple that this SingletonSet was initialized with.

Returns:
RealTuple

equals

public boolean equals(Object set)
See if this SingletonSet is equal to the Object in question. They are equal if they are the same object and have the same Units, CoordinateSystem, dimension and their getData() returns are the equal.

Specified by:
equals in interface SetIface
Specified by:
equals in class Set
Returns:
true if equal, otherwise false

hashCode

public int hashCode()
Returns the hash code of this instance.

Overrides:
hashCode in class Object
Returns:
The hash code of this instance.

cloneButType

public Object cloneButType(MathType type)
                    throws VisADException
Clone this SingletonSet, but change the MathType

Specified by:
cloneButType in interface SetIface
Specified by:
cloneButType in class Set
Parameters:
type - new MathType
Returns:
clone of this set with new MathType
Throws:
VisADException - couldn't create the new SingletonSet

longString

public String longString(String pre)
                  throws VisADException
Create string representation of this Set with a given prefix

Specified by:
longString in interface Data
Overrides:
longString in class Set
Parameters:
pre - Prefix for the string.
Returns:
String of the form pre + "SingletonSet: " + getData().toString()
Throws:
VisADException - couldn't create the longString