Package ucar.visad
Class VisADMath
java.lang.Object
ucar.visad.VisADMath
Utility class: provides support for mathematical operations on VisAD data
objects.
- Author:
- Steven R. Emmerson $Id: VisADMath.java,v 1.15 2005/05/13 18:34:06 jeffmc Exp $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final class
Provides support for indexing sample points. -
Method Summary
Modifier and TypeMethodDescriptionstatic Data
Adds two data objects together.static FlatField
curveIntegralOfGradient
(Field field) Returns the indefinite curve integral of a Field, which is assumed to be the gradient of a function.static Data
Divides one data object by another.static Data
Exponentiates a data object.static FlatField
fromReference
(FunctionType type, FlatField data) Transforms a FlatField object from a reference CoordinateSystem.static Data
fromReference
(MathType type, Data data) Transforms a data object from a reference CoordinateSystem.static RealTuple
fromReference
(RealTupleType type, RealTuple data) Transforms a RealTuple object from a reference CoordinateSystem.static IrregularSet
fromReference
(SetType type, SampledSet data) Transforms a SampledSet object from a reference CoordinateSystem.static Data
Inverts a data object by forming the reciprocal.static Data
Takes the natural logarithm of a data object.static void
Tests this class.static Data
Multiplies two data objects together.static Data
Negates a data object.static FlatField
newFlatField
(SampledSet set) Creates a FlatField from a SampledSet.static FlatField
newFlatField
(SampledSet set, MathType rangeType, CoordinateSystem rangeCoordinateSystem) Creates a FlatField from a SampledSet, a MathType for the range, and a CoordinateSystem for the range.static FlatField
newFlatField
(SampledSet domain, SampledSet range) Creates a FlatField from two SampledSet-s.static FlatField
newFlatField
(SampledSet domain, SampledSet range, MathType rangeType, CoordinateSystem rangeCoordinateSystem) Creates a FlatField from a domain SampledSet, a range SampledSet, and a CoordinateSystem for the range.static Data
Raises one data object to the power of another.static Data
Subtracts one data object from another.
-
Method Details
-
negate
Negates a data object.- Parameters:
data
- The data object to be negated.- Returns:
- The result of negating the data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
invert
Inverts a data object by forming the reciprocal.- Parameters:
data
- The data object to be inverted.- Returns:
- The result of inverting the data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
exp
Exponentiates a data object.- Parameters:
data
- The data object to be exponentiated.- Returns:
- The result of exponentiating the data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
log
Takes the natural logarithm of a data object.- Parameters:
data
- The data object to have the natural logarithm taken.- Returns:
- The result of taking the natural logarithm of the data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
add
public static Data add(Data data1, Data data2) throws UnimplementedException, TypeException, ArithmeticException, VisADException, RemoteException Adds two data objects together. The computational modes areData.WEIGHTED_AVERAGE
andData.NO_ERRORS
.- Parameters:
data1
- The first data object.data2
- The second data object.- Returns:
- The result of adding the two data objects together.
- Throws:
UnimplementedException
- Operation not yet implemented.TypeException
- MathTypes are incompatible.ArithmeticException
- Invalid operation between types.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
subtract
public static Data subtract(Data data1, Data data2) throws UnimplementedException, TypeException, ArithmeticException, VisADException, RemoteException Subtracts one data object from another.- Parameters:
data1
- The first data object.data2
- The second data object.- Returns:
- The result of subtracting the second data object from the first data object.
- Throws:
UnimplementedException
- Operation not yet implemented.TypeException
- MathTypes are incompatible.ArithmeticException
- Invalid operation between types.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
multiply
public static Data multiply(Data data1, Data data2) throws UnimplementedException, TypeException, ArithmeticException, VisADException, RemoteException Multiplies two data objects together. The computational modes areData.WEIGHTED_AVERAGE
andData.NO_ERRORS
.- Parameters:
data1
- The first data object.data2
- The second data object.- Returns:
- The result of multiplying the first data object by the second data object.
- Throws:
UnimplementedException
- Operation not yet implemented.TypeException
- MathTypes are incompatible.ArithmeticException
- Invalid operation between types.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
divide
public static Data divide(Data data1, Data data2) throws UnimplementedException, TypeException, ArithmeticException, VisADException, RemoteException Divides one data object by another.- Parameters:
data1
- The first data object.data2
- The second data object.- Returns:
- The result of dividing the first data object by the second data object.
- Throws:
UnimplementedException
- Operation not yet implemented.TypeException
- MathTypes are incompatible.ArithmeticException
- Invalid operation between types.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
pow
public static Data pow(Data base, Data exponent) throws UnimplementedException, TypeException, ArithmeticException, VisADException, RemoteException Raises one data object to the power of another.- Parameters:
base
- The data object to be raised by a power.exponent
- The exponent by which to raise the base.- Returns:
- The result of raising the base data object by the power of the exponent data object.
- Throws:
UnimplementedException
- Operation not yet implemented.TypeException
- MathTypes are incompatible.ArithmeticException
- Invalid operation between types.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
fromReference
public static Data fromReference(MathType type, Data data) throws TypeException, VisADException, RemoteException Transforms a data object from a reference CoordinateSystem. When the data object is a FlatField, then the transformation applies to its range and not its domain.- Parameters:
type
- The VisAD MathType of the returned data object. It shall be a RealTupleType, SetType, or FunctionType and shall have a CoordinateSystem, which shall be used in the transformation.data
- The data object to be transformed. The object shall be a Real, RealTuple, SampledSet, or FlatField.- Returns:
- The transformed data object. Its VisAD MathType
shall be
type
. - Throws:
TypeException
- Data object has illegal type.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
fromReference
public static RealTuple fromReference(RealTupleType type, RealTuple data) throws VisADException, RemoteException Transforms a RealTuple object from a reference CoordinateSystem.- Parameters:
type
- The MathType of the returned data object. It shall have a CoordinateSystem, which shall be used in the transformation.data
- The RealTuple object to be transformed.- Returns:
- The transformed data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
fromReference
Transforms a SampledSet object from a reference CoordinateSystem.- Parameters:
type
- The MathType of the returned data object.It shall have a CoordinateSystem, which shall be used in the transformation.data
- The SampledSet object to be transformed.- Returns:
- The transformed data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.
-
fromReference
public static FlatField fromReference(FunctionType type, FlatField data) throws VisADException, RemoteException Transforms a FlatField object from a reference CoordinateSystem.- Parameters:
type
- The MathType of the returned data object.It shall have a CoordinateSystem, which shall be used in the transformation.data
- The data object to be transformed.- Returns:
- The transformed data object.
- Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
curveIntegralOfGradient
public static FlatField curveIntegralOfGradient(Field field) throws FieldException, VisADException, RemoteException Returns the indefinite curve integral of a Field, which is assumed to be the gradient of a function. This method can handle any Field whose range is one of the following:Scalar derivative dy/dx RealTuple of partial derivatives (du/dx, du/dy, ...) Tuple of RealTuple-s of partial derivatives (one set of partial derivatives for each component of the resulting FlatField) ((du/dx, du/dy, ...), (dv/dx, dv/dy, ...), ...)
The domain points of the returned FlatField will be the same as the Field's. The type of the range of the returned FlatField will depend on the type of the range of the Field. The value of the range at the first domain point of the returned FlatField shall be arbitrarily set to (possibly vector) zero.- Parameters:
field
- The Field whose indefinite curve integral is to be computed.- Returns:
- The indefinite curve integral of the Field.
- Throws:
FieldException
- The Field has a non-flat range or range dimension of Field != domain dimension of Field.VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
newFlatField
Creates a FlatField from a SampledSet. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.- Parameters:
set
- The SampledSet.- Returns:
- The SampledSet promoted to a FlatField.
The MathType of the domain and range will
be the RealTupleType of the set (i.e.
((SetType)set.getType()).getDomain()
. The CoordinateSystem of the range will be that of the set (i.e.set.getCoordinateSystem()
). - Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
newFlatField
public static FlatField newFlatField(SampledSet domain, SampledSet range) throws VisADException, RemoteException Creates a FlatField from two SampledSet-s. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.- Parameters:
domain
- The domain of the FlatField.range
- The range of the FlatField.- Returns:
- The SampledSet promoted to a FlatField.
The MathType of the domain and range will
be the RealTupleType of the set (i.e.
((SetType)set.getType()).getDomain()
. The CoordinateSystem of the range will be that of the set (i.e.set.getCoordinateSystem()
). - Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
newFlatField
public static FlatField newFlatField(SampledSet set, MathType rangeType, CoordinateSystem rangeCoordinateSystem) throws VisADException, RemoteException Creates a FlatField from a SampledSet, a MathType for the range, and a CoordinateSystem for the range. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.- Parameters:
set
- The SampledSet.rangeType
- The MathType of the range for the returned FlatField.rangeCoordinateSystem
- The CoordinateSystem for the range of the returned FlatField. May benull
.- Returns:
- The SampledSet promoted to a FlatField.
The MathType of the domain will be
the RealTupleType of the set (i.e.
((SetType)set.getType()).getDomain()
. - Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
newFlatField
public static FlatField newFlatField(SampledSet domain, SampledSet range, MathType rangeType, CoordinateSystem rangeCoordinateSystem) throws VisADException, RemoteException Creates a FlatField from a domain SampledSet, a range SampledSet, and a CoordinateSystem for the range. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.- Parameters:
domain
- The domain SampledSet.range
- The range SampledSet.rangeType
- The MathType of the range for the returned FlatField.rangeCoordinateSystem
- The CoordinateSystem for the range of the returned FlatField. May benull
.- Returns:
- The SampledSet promoted to a FlatField.
The MathType of the domain will be
the RealTupleType of the set (i.e.
((SetType)set.getType()).getDomain()
. - Throws:
VisADException
- Couldn't create necessary VisAD object.RemoteException
- Java RMI failure.
-
main
Tests this class.- Parameters:
args
- Ignored.- Throws:
VisADException
- if a core VisAD failure occurs.RemoteException
- if a Java RMI failure occurs.
-