Package jahuwaldt.js.param
Class ParameterVector<Q extends javax.measure.quantity.Quantity>
- java.lang.Object
-
- org.jscience.mathematics.vector.Vector<Parameter<Q>>
-
- jahuwaldt.js.param.AbstractParamVector<Q,ParameterVector<Q>>
-
- jahuwaldt.js.param.ParameterVector<Q>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<javax.measure.Measurable<Q>>,javax.measure.Measurable<Q>,javolution.lang.Immutable,javolution.lang.Realtime,javolution.lang.ValueType,javolution.xml.XMLSerializable,GroupAdditive<Vector<Parameter<Q>>>,Structure<Vector<Parameter<Q>>>,VectorSpace<Vector<Parameter<Q>>,Parameter<Q>>,VectorSpaceNormed<Vector<Parameter<Q>>,Parameter<Q>>
public class ParameterVector<Q extends javax.measure.quantity.Quantity> extends AbstractParamVector<Q,ParameterVector<Q>> implements javolution.lang.ValueType, javolution.xml.XMLSerializable
This class represents an n-dimensional
vectorofParameterelements sharing the same units.Modified by: Joseph A. Huwaldt
- Version:
- February 23, 2025
- Author:
- Joseph A. Huwaldt Date: March 27, 2009
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends javax.measure.quantity.Quantity>
ParameterVector<T>asType(java.lang.Class<T> type)Casts this ParameterVector to a parameterized unit of specified nature or throw aClassCastExceptionif the dimension of the specified quantity and this parameter's unit dimension do not match.ParameterVector<Q>copy()Returns a copy of this vectorallocatedby the calling thread (possibly on the stack).ParameterVectorcross(Vector that)Returns the cross product of two vectors.ParameterVector<?>divide(Parameter<?> that)Returns this vector with each element divided by the specified divisor.booleanequals(java.lang.Object obj)Compares this ParameterVector against the specified object for strict equality (same values and same units).ParameterVector<Q>fromVector3D(Vector3D<Q> vector)Return the specifiedVector3Dobject as aParameterVectorinstance.Parameter<Q>get(int i)Returns the value of a Parameter from this vector.intgetDimension()Returns the number of elements held by this vector.javax.measure.unit.Unit<Q>getUnit()Returns the unit in which thevaluesin this vector are stated in.doublegetValue(int i)Returns the value of the Parameter in this vector as adouble, stated in this vector'sunit.inthashCode()Returns the hash code for this parameter.static voidmain(java.lang.String[] args)Tests the methods in this class.ParameterVector<Q>minus(Parameter<Q> that)Subtracts the supplied Parameter from each element of this vector and returns the result.ParameterVector<Q>minus(Vector<Parameter<Q>> that)Returns the difference between this vector and the one specified.doublenormValue()Returns theAbstractParamVector.norm(), magnitude, or length value of this vector.ParameterVector<Q>opposite()Returns the negation of this vector.ParameterVector<Q>plus(Parameter<Q> that)Returns the sum of this vector with the parameter specified.ParameterVector<Q>plus(Vector<Parameter<Q>> that)Returns the sum of this vector with the one specified.ParameterVector<Q>times(double k)Returns the product of this vector with the specified coefficient.ParameterVectortimes(Parameter k)Returns the product of this vector with the specified coefficient.Parametertimes(Vector that)Returns the dot product of this vector with the one specified.ParameterVectortimesEBE(Vector that)Returns the element-by-element product of this vector with the one specified.<R extends javax.measure.quantity.Quantity>
ParameterVector<R>to(javax.measure.unit.Unit<R> unit)Returns the equivalent to this vector but stated in the specified unit.Float64VectortoFloat64Vector()Returns the values stored in this vector, stated in this vector'sunit, as a Float64Vector.ParameterVector<javax.measure.quantity.Dimensionless>toUnitVector()Returns this vector converted to a unit vector by dividing all the vector's elements by the length (AbstractParamVector.norm()) of this vector.Vector3D<Q>toVector3D()Returns a Vector3D representation of this vector if possible.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(double x, double y, double z, javax.measure.unit.Unit<Q> unit)Returns aParameterVectorinstance holding the specifieddoublevalues stated in the specified units.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(double x, double y, javax.measure.unit.Unit<Q> unit)Returns a 2DParameterVectorinstance holding the specifieddoublevalues stated in the specified units.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(Parameter<Q>... values)Returns aParameterVectorinstance holding the specifiedParametervalues.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(Parameter<Q> x, Parameter<Q> y, Parameter<Q> z)Returns aParameterVectorinstance holding the specifiedParametervalues.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(java.util.List<Parameter<Q>> values)Returns aParameterVectorinstance holding the specifiedParametervalues.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(javax.measure.unit.Unit<Q> unit, double... values)Returns aParameterVectorinstance holding the specifieddoublevalues stated in the specified units.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(Vector<Parameter<Q>> vector)Returns aParameterVectorinstance containing the specified vector of Parameter values with compatible units.static <Q extends javax.measure.quantity.Quantity>
ParameterVector<Q>valueOf(Vector<Float64> vector, javax.measure.unit.Unit<Q> unit)Returns aParameterVectorinstance containing the specified vector of Float64 values stated in the specified units.
-
-
-
Field Detail
-
X
public static final int X
Constant used to identify the X (0) coordinate in the vector.- See Also:
- Constant Field Values
-
Y
public static final int Y
Constant used to identify the Y (1) coordinate in the vector.- See Also:
- Constant Field Values
-
Z
public static final int Z
Constant used to identify the Z (2) coordinate in the vector.- See Also:
- Constant Field Values
-
-
Method Detail
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(double x, double y, javax.measure.unit.Unit<Q> unit)
Returns a 2DParameterVectorinstance holding the specifieddoublevalues stated in the specified units.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
x- the x value stated in the specified unit.y- the y value stated in the specified unit.unit- the unit in which the coordinates are stated.- Returns:
- the vector having the specified values.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(double x, double y, double z, javax.measure.unit.Unit<Q> unit)
Returns aParameterVectorinstance holding the specifieddoublevalues stated in the specified units.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
x- the x value stated in the specified unit.y- the y value stated in the specified unit.z- the z value stated in the specified unit.unit- the unit in which the coordinates are stated.- Returns:
- the vector having the specified values.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(javax.measure.unit.Unit<Q> unit, double... values)
Returns aParameterVectorinstance holding the specifieddoublevalues stated in the specified units.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
unit- the unit in which the coordinates are stated.values- A list of values to store in the vector.- Returns:
- the vector having the specified values.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(Parameter<Q> x, Parameter<Q> y, Parameter<Q> z)
Returns aParameterVectorinstance holding the specifiedParametervalues. All the values are converted to the same units as the x value.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
x- the x value.y- the y value.z- the z value.- Returns:
- the vector having the specified values in the units of x.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(java.util.List<Parameter<Q>> values)
Returns aParameterVectorinstance holding the specifiedParametervalues. All the values are converted to the same units as the first value.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
values- A list of values to store in the vector.- Returns:
- the vector having the specified values in the units of x.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(Parameter<Q>... values)
Returns aParameterVectorinstance holding the specifiedParametervalues. All the values are converted to the same units as the first value.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
values- A list of values to store in the vector.- Returns:
- the vector having the specified values in the units of x.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(Vector<Float64> vector, javax.measure.unit.Unit<Q> unit)
Returns aParameterVectorinstance containing the specified vector of Float64 values stated in the specified units.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
vector- the vector of Float64 values stated in the specified unit.unit- the unit in which the coordinates are stated.- Returns:
- the vector having the specified values.
-
valueOf
public static <Q extends javax.measure.quantity.Quantity> ParameterVector<Q> valueOf(Vector<Parameter<Q>> vector)
Returns aParameterVectorinstance containing the specified vector of Parameter values with compatible units. All the values are converted to the same units as the 1st value.- Type Parameters:
Q- the quantity or type of the specified unit.- Parameters:
vector- the vector of Parameter values stated in the specified unit.- Returns:
- the vector having the specified values.
-
toVector3D
public Vector3D<Q> toVector3D()
Returns a Vector3D representation of this vector if possible.- Specified by:
toVector3Din classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Returns:
- A Vector3D that is equivalent to this vector
- Throws:
DimensionException- if this vector has any number of dimensions other than 3.
-
fromVector3D
public ParameterVector<Q> fromVector3D(Vector3D<Q> vector)
Return the specifiedVector3Dobject as aParameterVectorinstance.- Specified by:
fromVector3Din classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Parameters:
vector- TheVector3Dobject to be converted to aParameterVector.- Returns:
- A
ParameterVectorinstance that is equivalent to the suppliedVector3Dobject.
-
getDimension
public int getDimension()
Returns the number of elements held by this vector.- Specified by:
getDimensionin classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Returns:
- this vector dimension.
-
getValue
public double getValue(int i)
Returns the value of the Parameter in this vector as adouble, stated in this vector'sunit.- Overrides:
getValuein classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Parameters:
i- the dimension index.- Returns:
- the value of the Parameter at
i. - Throws:
java.lang.IndexOutOfBoundsException-(i < 0) || (i ≥ dimension())
-
normValue
public double normValue()
Returns theAbstractParamVector.norm(), magnitude, or length value of this vector.- Specified by:
normValuein classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Returns:
this.norm().doubleValue().
-
opposite
public ParameterVector<Q> opposite()
Returns the negation of this vector.
-
plus
public ParameterVector<Q> plus(Vector<Parameter<Q>> that)
Returns the sum of this vector with the one specified. The unit of the output vector will be the units of this vector.- Specified by:
plusin interfaceGroupAdditive<Q extends javax.measure.quantity.Quantity>- Specified by:
plusin classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Parameters:
that- the vector to be added.- Returns:
this + that.- Throws:
DimensionException- if vector dimensions are different.javax.measure.converter.ConversionException- if the input vector is not in units consistent with this vector.
-
plus
public ParameterVector<Q> plus(Parameter<Q> that)
Returns the sum of this vector with the parameter specified. The input parameter is added to each component of this vector. The unit of the output vector will be the units of this vector.- Specified by:
plusin classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Parameters:
that- the parameter to be added to each element of this vector.- Returns:
this + that.
-
minus
public ParameterVector<Q> minus(Vector<Parameter<Q>> that)
Returns the difference between this vector and the one specified. The unit of the output vector will be the units of this vector.- Overrides:
minusin classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Parameters:
that- the vector to be subtracted.- Returns:
this - that.- Throws:
DimensionException- if vector dimensions are different.javax.measure.converter.ConversionException- if the input vector is not in units consistent with this vector.
-
minus
public ParameterVector<Q> minus(Parameter<Q> that)
Subtracts the supplied Parameter from each element of this vector and returns the result. The unit of the output vector will be the units of this vector.- Specified by:
minusin classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Parameters:
that- the Parameter to be subtracted from each element of this vector.- Returns:
this - that.
-
times
public ParameterVector times(Parameter k)
Returns the product of this vector with the specified coefficient.- Specified by:
timesin interfaceVectorSpace<Vector<Parameter<Q extends javax.measure.quantity.Quantity>>,Parameter<Q extends javax.measure.quantity.Quantity>>- Specified by:
timesin classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Parameters:
k- the coefficient multiplier.- Returns:
this times k
-
times
public ParameterVector<Q> times(double k)
Returns the product of this vector with the specified coefficient.- Specified by:
timesin classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Parameters:
k- the coefficient multiplier.- Returns:
this times k
-
times
public Parameter times(Vector that)
Returns the dot product of this vector with the one specified.- Specified by:
timesin classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Parameters:
that- the vector multiplier.- Returns:
this times that- Throws:
DimensionException- ifthis.dimension() != that.dimension()- See Also:
- Wikipedia: Dot Product
-
timesEBE
public ParameterVector timesEBE(Vector that)
Returns the element-by-element product of this vector with the one specified.- Parameters:
that- the vector multiplier.- Returns:
this .* that- Throws:
DimensionException- ifthis.dimension() != that.dimension()
-
cross
public ParameterVector cross(Vector that)
Returns the cross product of two vectors.- Overrides:
crossin classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Parameters:
that- the vector multiplier.- Returns:
this x that- Throws:
DimensionException- if(that.getDimension() != this.getDimension())- See Also:
- Wikipedia: Cross Product
-
divide
public ParameterVector<?> divide(Parameter<?> that)
Returns this vector with each element divided by the specified divisor.- Parameters:
that- the divisor.- Returns:
this / that.
-
toUnitVector
public ParameterVector<javax.measure.quantity.Dimensionless> toUnitVector()
Returns this vector converted to a unit vector by dividing all the vector's elements by the length (AbstractParamVector.norm()) of this vector.- Returns:
- This vector converted to a unit vector by dividing all the vector's elements by the length of this vector.
-
copy
public ParameterVector<Q> copy()
Returns a copy of this vectorallocatedby the calling thread (possibly on the stack).
-
getUnit
public javax.measure.unit.Unit<Q> getUnit()
Returns the unit in which thevaluesin this vector are stated in.- Specified by:
getUnitin classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Returns:
- The unit in which the values in this vector are stated
-
to
public <R extends javax.measure.quantity.Quantity> ParameterVector<R> to(javax.measure.unit.Unit<R> unit)
Returns the equivalent to this vector but stated in the specified unit.- Specified by:
toin classAbstractParamVector<Q extends javax.measure.quantity.Quantity,ParameterVector<Q extends javax.measure.quantity.Quantity>>- Type Parameters:
R- The Quantity (unit type) of the vector being output.- Parameters:
unit- the unit of the vector to be returned.- Returns:
- a vector equivalent to this vector but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException- if the current model does not allows for conversion to the specified unit.
-
asType
public <T extends javax.measure.quantity.Quantity> ParameterVector<T> asType(java.lang.Class<T> type) throws java.lang.ClassCastException
Casts this ParameterVector to a parameterized unit of specified nature or throw aClassCastExceptionif the dimension of the specified quantity and this parameter's unit dimension do not match.- Type Parameters:
T- The quantity or type of the new unit- Parameters:
type- the quantity class identifying the nature of the unit.- Returns:
- this ParameterVector parameterized with the specified type.
- Throws:
java.lang.ClassCastException- if the dimension of this parameter's unit is different from the specified quantity dimension.java.lang.UnsupportedOperationException- if the specified quantity class does not have a public static field named "UNIT" holding the standard unit for the quantity.
-
toFloat64Vector
public Float64Vector toFloat64Vector()
Returns the values stored in this vector, stated in this vector'sunit, as a Float64Vector.- Returns:
- The values stored in this vector, stated in this vector's unit.
-
equals
public boolean equals(java.lang.Object obj)
Compares this ParameterVector against the specified object for strict equality (same values and same units).
-
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
hashCodein classVector<Parameter<Q extends javax.measure.quantity.Quantity>>- Returns:
- the hash code value.
- See Also:
Vector.equals(org.jscience.mathematics.vector.Vector<F>, java.util.Comparator<F>)
-
main
public static void main(java.lang.String[] args)
Tests the methods in this class.- Parameters:
args- the command-line arguments
-
-