# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.vector.doubles

## Interface Vector

• ### Method Summary

All Methods
Modifier and Type Method and Description
Vector add(double c)
Add a constant to all entries in this vector.
Vector add(Vector that)
$$this + that$$
double angle(Vector that)
Measure the angle, $$\theta$$, between this and that.
Vector deepCopy()
The implementation returns an instance created from this by the copy constructor of the class, or just this if the instance itself is immutable.
Vector divide(Vector that)
Divide this by that, entry-by-entry.
double get(int i)
Get the value at position i.
double innerProduct(Vector that)
Inner product in the Euclidean space is the dot product.
Vector minus(double c)
Subtract a constant from all entries in this vector.
Vector minus(Vector that)
$$this - that$$
Vector multiply(Vector that)
Multiply this by that, entry-by-entry.
double norm()
Compute the length or magnitude or Euclidean norm of a vector, namely, $$\|v\|$$.
double norm(double p)
Gets the $$L^p$$-norm $$\|v\|_p$$ of this vector.
Vector opposite()
Get the opposite of this vector.
Vector pow(double c)
Take the exponentiation of all entries in this vector, entry-by-entry.
Vector scaled(double c)
Scale this vector by a constant, entry-by-entry.
Vector scaled(Real c)
Scale this vector by a constant, entry-by-entry.
void set(int i, double value)
Change the value of an entry in this vector.
int size()
Get the length of this vector.
double[] toArray()
Cast this vector into a 1D double[].
Vector ZERO()
Get a 0-vector that has the same length as this vector.
• ### Method Detail

• #### size

int size()
Get the length of this vector.
Returns:
the vector length
• #### get

double get(int i)
Get the value at position i.
Parameters:
i - the position of a vector entry
Returns:
v[i]
• #### set

void set(int i,
double value)
Change the value of an entry in this vector. This is the only method that may change the entries of a vector.
Parameters:
i - the index of the entry to change. The indices are counting from 1, NOT 0.
value - the value to change to

Vector add(Vector that)
$$this + that$$
Specified by:
add in interface AbelianGroup<Vector>
Parameters:
that - a vector
Returns:
$$this + that$$
• #### minus

Vector minus(Vector that)
$$this - that$$
Specified by:
minus in interface AbelianGroup<Vector>
Parameters:
that - a vector
Returns:
$$this - that$$
• #### multiply

Vector multiply(Vector that)
Multiply this by that, entry-by-entry.
Parameters:
that - a vector
Returns:
$$this \cdot that$$
• #### divide

Vector divide(Vector that)
Divide this by that, entry-by-entry.
Parameters:
that - a vector
Returns:
$$this / that$$

Vector add(double c)
Add a constant to all entries in this vector.
Parameters:
c - a constant
Returns:
$$v + c$$
• #### minus

Vector minus(double c)
Subtract a constant from all entries in this vector.
Parameters:
c - a constant
Returns:
$$v - c$$
• #### innerProduct

double innerProduct(Vector that)
Inner product in the Euclidean space is the dot product.
Specified by:
innerProduct in interface HilbertSpace<Vector,Real>
Parameters:
that - a vector
Returns:
$$this \cdot that$$
Wikipedia: Dot product
• #### pow

Vector pow(double c)
Take the exponentiation of all entries in this vector, entry-by-entry.
Parameters:
c - a constant
Returns:
$$v ^ s$$
• #### scaled

Vector scaled(double c)
Scale this vector by a constant, entry-by-entry. Here is a way to get a unit version of the vector:
 vector.scaled(1. / vector.norm()) 
Parameters:
c - a constant
Returns:
$$c \times this$$
• #### scaled

Vector scaled(Real c)
Scale this vector by a constant, entry-by-entry. Here is a way to get a unit version of the vector:
 vector.scaled(1. / vector.norm()) 
Specified by:
scaled in interface VectorSpace<Vector,Real>
Parameters:
c - a constant
Returns:
$$c \times this$$
Wikipedia: Scalar multiplication
• #### norm

double norm()
Compute the length or magnitude or Euclidean norm of a vector, namely, $$\|v\|$$.
Specified by:
norm in interface BanachSpace<Vector,Real>
Returns:
the Euclidean norm
Wikipedia: Norm (mathematics)
• #### angle

double angle(Vector that)
Measure the angle, $$\theta$$, between this and that. That is, $this \cdot that = \|this\| \times \|that\| \times \cos \theta$
Specified by:
angle in interface HilbertSpace<Vector,Real>
Parameters:
that - a vector
Returns:
the angle, $$\theta$$, between this and that
• #### opposite

Vector opposite()
Get the opposite of this vector.
Specified by:
opposite in interface AbelianGroup<Vector>
Returns:
-v
• #### ZERO

Vector ZERO()
Get a 0-vector that has the same length as this vector.
Specified by:
ZERO in interface AbelianGroup<Vector>
Returns:
the 0-vector
• #### toArray

double[] toArray()
Cast this vector into a 1D double[].
Returns:
a copy of all vector entries as a double[]
• #### deepCopy

Vector deepCopy()
Description copied from interface: DeepCopyable
The implementation returns an instance created from this by the copy constructor of the class, or just this if the instance itself is immutable.
Specified by:
deepCopy in interface DeepCopyable
Returns:
an independent (deep) copy of the instance