public class GVector extends Object implements Serializable, Cloneable
Constructor and Description |
---|
GVector(double[] vector)
Constructs a new GVector from the specified array elements.
|
GVector(double[] vector,
int length)
Constructs a new GVector of the specified length and
initializes it by copying the specified number of elements from
the specified array.
|
GVector(GVector vector)
Constructs a new GVector from the specified vector.
|
GVector(int length)
Constructs a new GVector of the specified
length with all vector elements initialized to 0.
|
GVector(Tuple2f tuple)
Constructs a new GVector and copies the initial values
from the specified tuple.
|
GVector(Tuple3d tuple)
Constructs a new GVector and copies the initial values
from the specified tuple.
|
GVector(Tuple3f tuple)
Constructs a new GVector and copies the initial values
from the specified tuple.
|
GVector(Tuple4d tuple)
Constructs a new GVector and copies the initial values
from the specified tuple.
|
GVector(Tuple4f tuple)
Constructs a new GVector and copies the initial values
from the specified tuple.
|
Modifier and Type | Method and Description |
---|---|
void |
add(GVector vector)
Sets the value of this vector to sum of itself and the specified
vector
|
void |
add(GVector vector1,
GVector vector2)
Sets the value of this vector to the vector sum of vectors vector1
and vector2.
|
double |
angle(GVector v1)
Returns the (n-space) angle in radians between this vector and
the vector parameter; the return value is constrained to the
range [0,PI].
|
Object |
clone()
Creates a new object of the same class as this object.
|
double |
dot(GVector v1)
Returns the dot product of this vector and vector v1.
|
boolean |
epsilonEquals(GVector v1,
double epsilon)
Returns true if the L-infinite distance between this vector
and vector v1 is less than or equal to the epsilon parameter,
otherwise returns false.
|
boolean |
equals(GVector vector1)
Returns true if all of the data members of GVector vector1 are
equal to the corresponding data members in this GVector.
|
boolean |
equals(Object o1)
Returns true if the Object o1 is of type GMatrix and all of the
data members of o1 are equal to the corresponding data members in
this GMatrix.
|
double |
getElement(int index)
Retrieves the value at the specified index value of this vector.
|
int |
getSize()
Returns the number of elements in this vector.
|
int |
hashCode()
Returns a hash code value based on the data values in this
object.
|
void |
interpolate(GVector v1,
double alpha)
Linearly interpolates between this vector and vector v1 and
places the result into this tuple: this = (1-alpha)*this + alpha*v1.
|
void |
interpolate(GVector v1,
float alpha)
Deprecated.
Use interpolate(GVector, double) instead
|
void |
interpolate(GVector v1,
GVector v2,
double alpha)
Linearly interpolates between vectors v1 and v2 and places the
result into this tuple: this = (1-alpha)*v1 + alpha*v2.
|
void |
interpolate(GVector v1,
GVector v2,
float alpha)
Deprecated.
Use interpolate(GVector, GVector, double) instead
|
void |
LUDBackSolve(GMatrix LU,
GVector b,
GVector permutation)
LU Decomposition Back Solve; this method takes the LU matrix
and the permutation vector produced by the GMatrix method LUD
and solves the equation (LU)*x = b by placing the solution vector
x into this vector.
|
void |
mul(GMatrix m1,
GVector v1)
Multiplies matrix m1 times Vector v1 and places the result
into this vector (this = m1*v1).
|
void |
mul(GVector v1,
GMatrix m1)
Multiplies the transpose of vector v1 (ie, v1 becomes a row
vector with respect to the multiplication) times matrix m1
and places the result into this vector
(this = transpose(v1)*m1).
|
void |
negate()
Negates the value of this vector: this = -this.
|
double |
norm()
Returns the square root of the sum of the squares of this
vector (its length in n-dimensional space).
|
void |
normalize()
Normalizes this vector in place.
|
void |
normalize(GVector v1)
Sets the value of this vector to the normalization of vector v1.
|
double |
normSquared()
Returns the sum of the squares of this
vector (its length squared in n-dimensional space).
|
void |
scale(double s)
Scales this vector by the scale factor s.
|
void |
scale(double s,
GVector v1)
Sets the value of this vector to the scalar multiplication
of the scale factor with the vector v1.
|
void |
scaleAdd(double s,
GVector v1,
GVector v2)
Sets the value of this vector to the scalar multiplication by s
of vector v1 plus vector v2 (this = s*v1 + v2).
|
void |
set(double[] vector)
Sets the value of this vector to the values found in the array
parameter.
|
void |
set(GVector vector)
Sets the value of this vector to the values found in vector vector.
|
void |
set(Tuple2f tuple)
Sets the value of this vector to the values in tuple
|
void |
set(Tuple3d tuple)
Sets the value of this vector to the values in tuple
|
void |
set(Tuple3f tuple)
Sets the value of this vector to the values in tuple
|
void |
set(Tuple4d tuple)
Sets the value of this vector to the values in tuple
|
void |
set(Tuple4f tuple)
Sets the value of this vector to the values in tuple
|
void |
setElement(int index,
double value)
Modifies the value at the specified index of this vector.
|
void |
setSize(int length)
Changes the size of this vector dynamically.
|
void |
sub(GVector vector)
Sets the value of this vector to the vector difference of itself
and vector (this = this - vector).
|
void |
sub(GVector vector1,
GVector vector2)
Sets the value of this vector to the vector difference
of vectors vector1 and vector2 (this = vector1 - vector2).
|
void |
SVDBackSolve(GMatrix U,
GMatrix W,
GMatrix V,
GVector b)
Solves for x in Ax = b, where x is this vector (nx1), A is mxn,
b is mx1, and A = U*W*transpose(V); U,W,V must
be precomputed and can be found by taking the singular value
decomposition (SVD) of A using the method SVD found in the
GMatrix class.
|
String |
toString()
Returns a string that contains the values of this GVector.
|
void |
zero()
Sets all the values in this vector to zero.
|
public GVector(int length)
length
- the number of elements in this GVector.public GVector(double[] vector)
vector
- the values for the new GVector.public GVector(GVector vector)
vector
- the source GVector for this new GVector.public GVector(Tuple2f tuple)
tuple
- the source for the new GVector's initial valuespublic GVector(Tuple3f tuple)
tuple
- the source for the new GVector's initial valuespublic GVector(Tuple3d tuple)
tuple
- the source for the new GVector's initial valuespublic GVector(Tuple4f tuple)
tuple
- the source for the new GVector's initial valuespublic GVector(Tuple4d tuple)
tuple
- the source for the new GVector's initial valuespublic GVector(double[] vector, int length)
length
elements (i.e., vector.length
>=
length
. The length of this new GVector is set to
the specified length.vector
- The array from which the values will be copied.length
- The number of values copied from the array.public final double norm()
public final double normSquared()
public final void normalize(GVector v1)
v1
- the un-normalized vectorpublic final void normalize()
public final void scale(double s, GVector v1)
s
- the scalar valuev1
- the source vectorpublic final void scale(double s)
s
- the scalar valuepublic final void scaleAdd(double s, GVector v1, GVector v2)
s
- the scalar valuev1
- the vector to be multipliedv2
- the vector to be addedpublic final void add(GVector vector)
vector
- the second vectorpublic final void add(GVector vector1, GVector vector2)
vector1
- the first vectorvector2
- the second vectorpublic final void sub(GVector vector)
vector
- the other vectorpublic final void sub(GVector vector1, GVector vector2)
vector1
- the first vectorvector2
- the second vectorpublic final void mul(GMatrix m1, GVector v1)
m1
- The matrix in the multiplicationv1
- The vector that is multipliedpublic final void mul(GVector v1, GMatrix m1)
m1
- The matrix in the multiplicationv1
- The vector that is temporarily transposedpublic final void negate()
public final void zero()
public final void setSize(int length)
length
- number of desired elements in this vectorpublic final void set(double[] vector)
vector
- the source arraypublic final void set(GVector vector)
vector
- the source vectorpublic final void set(Tuple2f tuple)
tuple
- the source for the new GVector's new valuespublic final void set(Tuple3f tuple)
tuple
- the source for the new GVector's new valuespublic final void set(Tuple3d tuple)
tuple
- the source for the new GVector's new valuespublic final void set(Tuple4f tuple)
tuple
- the source for the new GVector's new valuespublic final void set(Tuple4d tuple)
tuple
- the source for the new GVector's new valuespublic final int getSize()
public final double getElement(int index)
index
- the index of the element to retrieve (zero indexed)public final void setElement(int index, double value)
index
- the index if the element to modify (zero indexed)value
- the new vector element valuepublic String toString()
public int hashCode()
public boolean equals(GVector vector1)
vector1
- The vector with which the comparison is made.public boolean equals(Object o1)
public boolean epsilonEquals(GVector v1, double epsilon)
v1
- The vector to be compared to this vectorepsilon
- the threshold valuepublic final double dot(GVector v1)
v1
- the other vectorpublic final void SVDBackSolve(GMatrix U, GMatrix W, GMatrix V, GVector b)
U
- The U matrix produced by the GMatrix method SVDW
- The W matrix produced by the GMatrix method SVDV
- The V matrix produced by the GMatrix method SVDb
- The b vector in the linear equation Ax = bpublic final void LUDBackSolve(GMatrix LU, GVector b, GVector permutation)
LU
- The matrix into which the lower and upper decompostions
have been placedb
- The b vector in the equation (LU)*x = bpermutation
- The row permuations that were necessary to
produce the LU matrix parameterpublic final double angle(GVector v1)
v1
- The other vectorpublic final void interpolate(GVector v1, GVector v2, float alpha)
public final void interpolate(GVector v1, float alpha)
public final void interpolate(GVector v1, GVector v2, double alpha)
v1
- the first vectorv2
- the second vectoralpha
- the alpha interpolation parameterpublic final void interpolate(GVector v1, double alpha)
v1
- the first vectoralpha
- the alpha interpolation parameterpublic Object clone()
clone
in class Object
OutOfMemoryError
- if there is not enough memory.Cloneable
Copyright © 2016–2022 SciJava. All rights reserved.