## visad
Class DerivedUnit

    java.lang.Object
      visad.Unit
          visad.DerivedUnit

All Implemented Interfaces:
  Serializable

public final class DerivedUnit
extends Unit
implements Serializable

A class that represents a unit consisting of zero or more base units.

See Also:
  Serialized Form

Nested Class Summary
`(package private) static class` `DerivedUnit.Op`

Field Summary
`(package private) Factor[]` `factors` The array of individual base-unit factors that make up this unit.

Fields inherited from class visad.Unit
`hashCode, hashCodeSet`

Constructor Summary
`DerivedUnit()` Construct a dimensionless derived unit.
`DerivedUnit(BaseUnit baseUnit)` Construct a derived unit from a base unit.
`DerivedUnit(BaseUnit[] baseUnits, int[] powers)` Construct a derived unit from an array base units and powers.
`DerivedUnit(BaseUnit[] baseUnits, int[] powers, String identifier)` Construct a derived unit from an array base units, powers, and an identifier.
`DerivedUnit(DerivedUnit that, String identifier)` Construct a derived unit from a derived unit and an identifier.
`DerivedUnit(String identifier)` Construct a dimensionless derived unit with an identifier.

Method Summary
`(package private) Unit` `divide(DerivedUnit that)` Divide a derived unit by a derived unit.
`Unit` `divide(Unit that)` Divide a derived unit by another unit.
`protected Unit` `divideInto(Unit that)` Divide a derived unit into another unit.
`boolean` `equals(Unit unit)` Indicates if this instance equals a unit.
`String` `getDefinition()` Return the definition of this unit.
`int` `hashCode()` Returns the hash code of this instance.
`boolean` `isConvertible(Unit unit)` Indicate whether this unit is convertible with another unit.
`boolean` `isDimensionless()` Indicates if this instance is dimensionless.
`static void` `main(String[] args)` Test this class.
`Unit` `multiply(DerivedUnit that)` Multiply a derived unit by a derived unit.
`Unit` `multiply(Unit that)` Multiply a derived unit by another unit.
`protected static Factor[]` `newFactors(BaseUnit[] baseUnits, int[] powers)` Creates an array of Factor-s from arrays of base units and powers.
`Unit` `pow(double power)` Raise a derived unit to a power.
`Unit` `pow(int power)` Raise a derived unit to a power.
`protected Unit` `protectedClone(String identifier)` Clones this unit, changing the identifier.
`(package private) boolean` `reciprocalDimensionality(DerivedUnit that)` Indicate whether or not this unit has the reciprocal dimensionality of a derived unit.
`Unit` `root(int root)` Returns the N-th root of this unit.
`(package private) boolean` `sameDimensionality(DerivedUnit that)` Indicate whether or not this unit has the same dimensionality as a derived unit.
`Unit` `scale(double amount)` Scale this unit by an amount.
`Unit` `shift(double offset)` Shift this unit by an amount.
`(package private) double[]` `toThat(double[] values, DerivedUnit that)` Convert values from this unit to a derived unit.
`(package private) double[]` `toThat(double[] values, DerivedUnit that, boolean copy)` Convert values from this unit to a derived unit.
`double[]` `toThat(double[] values, Unit that)` Convert values from this unit to another unit.
`double[]` `toThat(double[] values, Unit that, boolean copy)` Convert values from this unit to another unit.
`(package private) float[]` `toThat(float[] values, DerivedUnit that)` Convert values from this unit to a derived unit.
`(package private) float[]` `toThat(float[] values, DerivedUnit that, boolean copy)` Convert values from this unit to a derived unit.
`float[]` `toThat(float[] values, Unit that)` Convert values from this unit to another unit.
`float[]` `toThat(float[] values, Unit that, boolean copy)` Convert values from this unit to another unit.
`(package private) double[]` `toThis(double[] values, DerivedUnit that)` Convert values to this unit from a derived unit.
`(package private) double[]` `toThis(double[] values, DerivedUnit that, boolean copy)` Convert values to this unit from a derived unit.
`double[]` `toThis(double[] values, Unit that)` Convert values to this unit from another unit.
`double[]` `toThis(double[] values, Unit that, boolean copy)` Convert values to this unit from another unit.
`(package private) float[]` `toThis(float[] values, DerivedUnit that)` Convert values to this unit from a derived unit.
`(package private) float[]` `toThis(float[] values, DerivedUnit that, boolean copy)` Convert values to this unit from a derived unit.
`float[]` `toThis(float[] values, Unit that)` Convert values to this unit from another unit.
`float[]` `toThis(float[] values, Unit that, boolean copy)` Convert values to this unit from another unit.

Methods inherited from class visad.Unit
`adjustCheckAndCache, canConvert, canConvertArray, clone, convertTuple, convertTuple, convertTuple, convertTuple, copyUnitsArray, equals, getAbsoluteUnit, getIdentifier, scale, sqrt, toString, toThat, toThis, transformUnits, transformUnits, transformUnits, transformUnits`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### factors

    Factor[] factors

  The array of individual base-unit factors that make up this unit. The following is effectively "final" in that it is only set in constructors and never altered. Unfortunately, the JDK 1.1.2 javac(1) compiler on our SunOS 5.5 systems doesn't recognize this fact; hence, the "final" is commented-out.

Constructor Detail

### DerivedUnit

    public DerivedUnit()

  Construct a dimensionless derived unit. The identifier of the unit will be empty.

### DerivedUnit

    public DerivedUnit(String identifier)

  Construct a dimensionless derived unit with an identifier.

Parameters:
  `identifier` - Name or abbreviation for the unit. May be `null` or empty.

### DerivedUnit

    public DerivedUnit(BaseUnit baseUnit)

  Construct a derived unit from a base unit. The identifier of the unit will be that of the base unit.

Parameters:
  `baseUnit` - The base unit.

### DerivedUnit

    public DerivedUnit(BaseUnit[] baseUnits,
                       int[] powers)

  Construct a derived unit from an array base units and powers. The identifier of the unit with be that of the base unit if there's only one base unit; otherwise, the identifier will be `null`.

Parameters:
  `baseUnits` - The array of base units (e.g. {m, s}).
  `powers` - The array of powers (e.g. {1, -1} to create a m/s unit).

### DerivedUnit

    public DerivedUnit(BaseUnit[] baseUnits,
                       int[] powers,
                       String identifier)

  Construct a derived unit from an array base units, powers, and an identifier.

Parameters:
  `baseUnits` - The array of base units (e.g. {m, s}).
  `powers` - The array of powers (e.g. {1, -1} to create a m/s unit).
  `identifier` - Name or abbreviation for the unit. May be `null` or empty.

### DerivedUnit

    public DerivedUnit(DerivedUnit that,
                       String identifier)

  Construct a derived unit from a derived unit and an identifier.

Parameters:
  `that` - The derived unit.
  `identifier` - Name or abbreviation for the unit. May be `null` or empty.

Method Detail

### newFactors

    protected static Factor[] newFactors(BaseUnit[] baseUnits,
                                         int[] powers)

  Creates an array of Factor-s from arrays of base units and powers.

  Parameters:
    `baseUnits` - The array of base units (e.g. {m, s}).
    `powers` - The array of powers (e.g. {1, -1} to create a m/s unit).
  Returns:
    An array of `Factor`s equivalent to the given base units and powers.

### isDimensionless

    public boolean isDimensionless()

  Indicates if this instance is dimensionless. A unit is dimensionless if it is a measure of a dimensionless quantity like angle or concentration. Examples of dimensionless units include radian, degree, steradian, and "g/kg".

  Specified by:
    `isDimensionless` in class `Unit`
  Returns:
    True if an only if this unit is dimensionless.

### protectedClone

    protected Unit protectedClone(String identifier)

  Clones this unit, changing the identifier.

  Specified by:
    `protectedClone` in class `Unit`
  Parameters:
    `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.
  Returns:
    A unit equal to this unit but with the given identifier.

### pow

    public Unit pow(int power)

  Raise a derived unit to a power.

  Specified by:
    `pow` in class `Unit`
  Parameters:
    `power` - The power to raise this unit by.
  Returns:
    The unit resulting from raising this unit to `power`.

### root

    public Unit root(int root)
              throws IllegalArgumentException

  Returns the N-th root of this unit.

  Specified by:
    `root` in class `Unit`
  Parameters:
    `root` - The root to take (e.g. 2 means square root). May not be zero.
  Returns:
    The unit corresponding to the `root`-th root of this unit.
  Throws:
    `IllegalArgumentException` - `root` is zero or the result would have a non-integral unit dimension.

### pow

    public Unit pow(double power)
             throws IllegalArgumentException

  Raise a derived unit to a power.

  Specified by:
    `pow` in class `Unit`
  Parameters:
    `power` - The power to raise this unit by. If this unit is not dimensionless, then the value must be an integer or the reciprocal of an integer.
  Returns:
    The unit resulting from raising this unit to `power`.
  Throws:
    `IllegalArgumentException` - This unit is not dimensionless and `power` is neither an integer nor the reciprocal of an integer.

### scale

    public Unit scale(double amount)
               throws UnitException

  Scale this unit by an amount.

  Overrides:
    `scale` in class `Unit`
  Parameters:
    `amount` - The amount by which to scale this unit. E.g. Unit yard = meter.scale(0.9144);
  Returns:
    A unit equal this this unit scaled by the given amount.
  Throws:
    `UnitException` - This unit cannot be scaled.

### shift

    public Unit shift(double offset)
               throws UnitException

  Shift this unit by an amount.

  Overrides:
    `shift` in class `Unit`
  Parameters:
    `offset` - The amount by which to shift this unit. E.g. Unit celsius = kelvin.shift(273.15);
  Returns:
    A unit equal to this unit with the origin shifted to the given point.
  Throws:
    `UnitException` - The unit subclass is unknown.

### getDefinition

    public String getDefinition()

  Return the definition of this unit.

  Specified by:
    `getDefinition` in class `Unit`
  Returns:
    The definition of this unit (e.g. "m.s-1").

### main

    public static void main(String[] args)
                     throws UnitException

  Test this class.

  Parameters:
    `args` - Arguments (ignored).
  Throws:
    `UnitException` - A problem occurred.

### multiply

    public Unit multiply(Unit that)
                  throws UnitException

  Multiply a derived unit by another unit.

  Specified by:
    `multiply` in class `Unit`
  Parameters:
    `that` - The unit with which to multiply this unit.
  Returns:
    The product of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### multiply

    public Unit multiply(DerivedUnit that)

  Multiply a derived unit by a derived unit.

  Parameters:
    `that` - The derived unit with which to multiply this unit.
  Returns:
    The product of the two units.

### divide

    public Unit divide(Unit that)
                throws UnitException

  Divide a derived unit by another unit.

  Specified by:
    `divide` in class `Unit`
  Parameters:
    `that` - The unit to divide into this unit.
  Returns:
    The quotient of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### divide

    Unit divide(DerivedUnit that)

  Divide a derived unit by a derived unit.

  Parameters:
    `that` - The derived unit to divide into this unit.
  Returns:
    The quotient of the two units.

### divideInto

    protected Unit divideInto(Unit that)
                       throws UnitException

  Divide a derived unit into another unit.

  Specified by:
    `divideInto` in class `Unit`
  Parameters:
    `that` - The unit to be divided by this unit.
  Returns:
    The quotient of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### sameDimensionality

    boolean sameDimensionality(DerivedUnit that)

  Indicate whether or not this unit has the same dimensionality as a derived unit.

  Parameters:
    `that` - The derived unit.
  Returns:
    `true` if and only if both units have the same dimensionality (e.g. Length/Time).

### reciprocalDimensionality

    boolean reciprocalDimensionality(DerivedUnit that)

  Indicate whether or not this unit has the reciprocal dimensionality of a derived unit.

  Parameters:
    `that` - The derived unit.
  Returns:
    `true` if and only if the unit dimensionalities are reciprocals of each other (e.g. Length/Time and Time/Length).

### toThis

    public double[] toThis(double[] values,
                           Unit that)
                    throws UnitException

  Convert values to this unit from another unit.

  Specified by:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public float[] toThis(float[] values,
                          Unit that)
                   throws UnitException

  Convert values to this unit from another unit.

  Specified by:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public double[] toThis(double[] values,
                           Unit that,
                           boolean copy)
                    throws UnitException

  Convert values to this unit from another unit.

  Overrides:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public float[] toThis(float[] values,
                          Unit that,
                          boolean copy)
                   throws UnitException

  Convert values to this unit from another unit.

  Overrides:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    double[] toThis(double[] values,
                    DerivedUnit that)
              throws UnitException

  Convert values to this unit from a derived unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    float[] toThis(float[] values,
                   DerivedUnit that)
             throws UnitException

  Convert values to this unit from a derived unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    double[] toThis(double[] values,
                    DerivedUnit that,
                    boolean copy)
              throws UnitException

  Convert values to this unit from a derived unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    float[] toThis(float[] values,
                   DerivedUnit that,
                   boolean copy)
             throws UnitException

  Convert values to this unit from a derived unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public double[] toThat(double[] values,
                           Unit that)
                    throws UnitException

  Convert values from this unit to another unit.

  Specified by:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public float[] toThat(float[] values,
                          Unit that)
                   throws UnitException

  Convert values from this unit to another unit.

  Specified by:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    double[] toThat(double[] values,
                    DerivedUnit that)
              throws UnitException

  Convert values from this unit to a derived unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    float[] toThat(float[] values,
                   DerivedUnit that)
             throws UnitException

  Convert values from this unit to a derived unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public double[] toThat(double[] values,
                           Unit that,
                           boolean copy)
                    throws UnitException

  Convert values from this unit to another unit.

  Overrides:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public float[] toThat(float[] values,
                          Unit that,
                          boolean copy)
                   throws UnitException

  Convert values from this unit to another unit.

  Overrides:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    double[] toThat(double[] values,
                    DerivedUnit that,
                    boolean copy)
              throws UnitException

  Convert values from this unit to a derived unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    float[] toThat(float[] values,
                   DerivedUnit that,
                   boolean copy)
             throws UnitException

  Convert values from this unit to a derived unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### isConvertible

    public boolean isConvertible(Unit unit)

  Indicate whether this unit is convertible with another unit. If one unit is convertible with another, then the `toThis(...)`/ and `toThat(...)` methods will not throw a UnitException. Unit A is convertible with unit B if and only if unit B is convertible with unit A; hence, calling-order is irrelevant.

  Specified by:
    `isConvertible` in class `Unit`
  Parameters:
    `unit` - The other unit.
  Returns:
    True if and only if this unit is convertible with the other unit.

### equals

    public boolean equals(Unit unit)

  Indicates if this instance equals a unit.

  Specified by:
    `equals` in class `Unit`
  Parameters:
    `unit` - The unit.
  Returns:
    `true` if and only if this instance equals the unit.

### hashCode

    public int hashCode()

  Returns the hash code of this instance. `Object.hashCode()` should be overridden whenever `Object.equals(Object)` is.

  Specified by:
    `hashCode` in class `Unit`
  Returns:
    The hash code of this instance (includes the values).