JScience v3.3

org.jscience.physics.measures
Class MeasureVector<Q extends Quantity>

java.lang.Object
  extended by javolution.context.RealtimeObject
      extended by org.jscience.mathematics.vectors.Vector<Measure<?>>
          extended by org.jscience.physics.measures.MeasureVector<Q>
All Implemented Interfaces:
java.io.Serializable, Realtime, Immutable, GroupAdditive<Vector<Measure<?>>>, Structure<Vector<Measure<?>>>, VectorSpace<Vector<Measure<?>>,Measure<?>>, VectorSpaceNormed<Vector<Measure<?>>,Measure<?>>

public class MeasureVector<Q extends Quantity>
extends Vector<Measure<?>>
implements VectorSpaceNormed<Vector<Measure<?>>,Measure<?>>

This class represents a measurement vector for which all components are of the same type.

Measure vectors are typically 2 or 3 dimensional. For example:

     class Velocity2D extends MeasureVector<Velocity> { ... }
     MeasureVector<Length> xyz = MeasureVector.valueOf(METER, 2.0, -4.0, 3.0);
     

Version:
3.1, April 2, 2006
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javolution.context.RealtimeObject
RealtimeObject.Factory<T extends RealtimeObject>
 
Nested classes/interfaces inherited from interface javolution.context.Realtime
Realtime.ObjectSpace
 
Constructor Summary
MeasureVector(Measure<Q>... elements)
          Creates a measurement vector holding the specified elements.
 
Method Summary
 Measure<Q> get(int i)
          Returns a single element from this vector.
 int getDimension()
          Returns the number of elements held by this vector.
 Measure<Q> norm()
          Returns the Euclidian norm of this vector (square root of the dot product of this vector and itself).
 MeasureVector<Q> opposite()
          Returns the negation of this vector.
 MeasureVector<Q> plus(Vector<Measure<?>> that)
          Returns the sum of this vector with the one specified.
static void recycle(MeasureVector vector)
          Recycles the specified vector immediately.
 MeasureVector<? extends Quantity> times(Measure k)
          Returns the product of this vector with the specified coefficient.
 Measure<?> times(Vector<Measure<?>> that)
          Returns the dot product of this vector with the one specified.
<R extends Quantity>
MeasureVector<R>
to(Unit<R> unit)
          Returns the measurement vector equivalent to this vector but stated in the specified unit.
static
<Q extends Quantity>
MeasureVector<Q>
valueOf(Measure<Q>... elements)
          Returns a new measurement vector (potentially recycled) holding the specified elements.
static
<Q extends Quantity>
MeasureVector<Q>
valueOf(Unit<Q> unit, double... values)
          Returns the approximate measurement vector holding the specified values stated in the specified unit.
static
<Q extends Quantity>
MeasureVector<Q>
valueOf(Unit<Q> unit, long... values)
          Returns the exact measurement vector holding the specified values stated in the specified unit.
static
<Q extends Quantity>
MeasureVector<Q>
valueOf(Unit<Q> unit, Vector<Measure<?>> that)
          Returns a MeasureVector stated in the specified unit equivalent to the specified vector
 
Methods inherited from class org.jscience.mathematics.vectors.Vector
cross, equals, equals, hashCode, minus, toText, valueOf, valueOf
 
Methods inherited from class javolution.context.RealtimeObject
export, isLocal, move, moveHeap, preserve, toString, unpreserve
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javolution.context.Realtime
move, toText
 

Constructor Detail

MeasureVector

public MeasureVector(Measure<Q>... elements)
Creates a measurement vector holding the specified elements.

Parameters:
elements - the vector elements.
Method Detail

valueOf

public static <Q extends Quantity> MeasureVector<Q> valueOf(Measure<Q>... elements)
Returns a new measurement vector (potentially recycled) holding the specified elements.

Parameters:
elements - the vector elements.
Returns:
the vector having the specified elements.
Throws:
DimensionException - if the rows do not have the same length.
See Also:
ObjectFactory.object()

valueOf

public static <Q extends Quantity> MeasureVector<Q> valueOf(Unit<Q> unit,
                                                            Vector<Measure<?>> that)
Returns a MeasureVector stated in the specified unit equivalent to the specified vector

Parameters:
unit - the unit in which the measurements are stated.
that - the vector to convert.
Returns:
that or new equivalent dense vector.

valueOf

public static <Q extends Quantity> MeasureVector<Q> valueOf(Unit<Q> unit,
                                                            long... values)
Returns the exact measurement vector holding the specified values stated in the specified unit.

Parameters:
unit - the unit in which the measurements are stated.
values - the exact values stated in the specified unit.
Returns:
the corresponding measurement vector.

valueOf

public static <Q extends Quantity> MeasureVector<Q> valueOf(Unit<Q> unit,
                                                            double... values)
Returns the approximate measurement vector holding the specified values stated in the specified unit.

Parameters:
unit - the unit in which the measurements are stated.
values - the approximate values stated in the specified unit.
Returns:
the corresponding measurement vector.

recycle

public static void recycle(MeasureVector vector)
Recycles the specified vector immediately.

Parameters:
vector - the vector being recycled.
See Also:
ObjectFactory.recycle(Object)

norm

public Measure<Q> norm()
Returns the Euclidian norm of this vector (square root of the dot product of this vector and itself).

Specified by:
norm in interface VectorSpaceNormed<Vector<Measure<?>>,Measure<?>>
Returns:
sqrt(this · this).
See Also:
Wikipedia: Vector Norm

to

public <R extends Quantity> MeasureVector<R> to(Unit<R> unit)
Returns the measurement vector equivalent to this vector but stated in the specified unit.

Parameters:
unit - the unit of the measurements to be returned.
Returns:
a measurement vector equivalent to this vector but whose elements are stated in the specified unit.
Throws:
ConversionException - if the current model does not allows for conversion to the specified unit.

getDimension

public final int getDimension()
Description copied from class: Vector
Returns the number of elements held by this vector.

Specified by:
getDimension in class Vector<Measure<?>>
Returns:
this vector dimension.

get

public final Measure<Q> get(int i)
Description copied from class: Vector
Returns a single element from this vector.

Specified by:
get in class Vector<Measure<?>>
Parameters:
i - the element index (range [0..n[).
Returns:
the element at i.

opposite

public MeasureVector<Q> opposite()
Description copied from class: Vector
Returns the negation of this vector.

Specified by:
opposite in interface GroupAdditive<Vector<Measure<?>>>
Specified by:
opposite in class Vector<Measure<?>>
Returns:
-this.

plus

public MeasureVector<Q> plus(Vector<Measure<?>> that)
Description copied from class: Vector
Returns the sum of this vector with the one specified.

Specified by:
plus in interface GroupAdditive<Vector<Measure<?>>>
Specified by:
plus in class Vector<Measure<?>>
Parameters:
that - the vector to be added.
Returns:
this + that.

times

public MeasureVector<? extends Quantity> times(Measure k)
Description copied from class: Vector
Returns the product of this vector with the specified coefficient.

Specified by:
times in interface VectorSpace<Vector<Measure<?>>,Measure<?>>
Specified by:
times in class Vector<Measure<?>>
Parameters:
k - the coefficient multiplier.
Returns:
this · k

times

public Measure<?> times(Vector<Measure<?>> that)
Description copied from class: Vector
Returns the dot product of this vector with the one specified.

Specified by:
times in class Vector<Measure<?>>
Parameters:
that - the vector multiplier.
Returns:
this · that
See Also:
Wikipedia: Dot Product

JScience v3.3

Copyright © 2006 JScience.