## Class Vector

• All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DenseVector, SparseVector

```public abstract class Vector
extends Object
implements Serializable```
The Vector class defines some common methods for both DenseVector and SparseVector.
Serialized Form
• ### Constructor Summary

Constructors
Constructor and Description
`Vector()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`abstract void` ```add(int i, double val)```
Add the i-th element of the vector by value "val".
`abstract Vector` `append(double v)`
Create a new vector by adding an element to the end of the vector.
`abstract double` `dot(Vector vec)`
Compute the dot product with another vector.
`abstract double` `get(int i)`
Get the i-th element of the vector.
`abstract VectorIterator` `iterator()`
Get the iterator of the vector.
`abstract Vector` `minus(Vector vec)`
Create a new vector by subtracting another vector.
`abstract void` `normalizeEqual(double p)`
Normalize the vector.
`abstract double` `normInf()`
Return the Inf norm of the vector.
`abstract double` `normL1()`
Return the L1 norm of the vector.
`abstract double` `normL2()`
Return the L2 norm of the vector.
`abstract double` `normL2Square()`
Return the square of L2 norm of the vector.
`abstract DenseMatrix` `outer()`
Compute the outer product with itself.
`abstract Vector` `plus(Vector vec)`
Create a new vector by plussing another vector.
`abstract Vector` `prefix(double v)`
Create a new vector by adding an element to the head of the vector.
`abstract Vector` `scale(double v)`
Scale the vector by value "v" and create a new vector to store the result.
`abstract void` `scaleEqual(double v)`
Scale the vector by value "v".
`abstract void` ```set(int i, double val)```
Set the i-th element of the vector to value "val".
`abstract int` `size()`
Get the size of the vector.
`abstract Vector` `slice(int[] indexes)`
Slice the vector.
`abstract void` ```standardizeEqual(double mean, double stdvar)```
Standardize the vector.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### Vector

`public Vector()`
• ### Method Detail

• #### size

`public abstract int size()`
Get the size of the vector.
• #### get

`public abstract double get(int i)`
Get the i-th element of the vector.
• #### set

```public abstract void set(int i,
double val)```
Set the i-th element of the vector to value "val".

```public abstract void add(int i,
double val)```
Add the i-th element of the vector by value "val".
• #### normL1

`public abstract double normL1()`
Return the L1 norm of the vector.
• #### normInf

`public abstract double normInf()`
Return the Inf norm of the vector.
• #### normL2

`public abstract double normL2()`
Return the L2 norm of the vector.
• #### normL2Square

`public abstract double normL2Square()`
Return the square of L2 norm of the vector.
• #### scale

`public abstract Vector scale(double v)`
Scale the vector by value "v" and create a new vector to store the result.
• #### scaleEqual

`public abstract void scaleEqual(double v)`
Scale the vector by value "v".
• #### normalizeEqual

`public abstract void normalizeEqual(double p)`
Normalize the vector.
• #### standardizeEqual

```public abstract void standardizeEqual(double mean,
double stdvar)```
Standardize the vector.
• #### prefix

`public abstract Vector prefix(double v)`
Create a new vector by adding an element to the head of the vector.
• #### append

`public abstract Vector append(double v)`
Create a new vector by adding an element to the end of the vector.
• #### plus

`public abstract Vector plus(Vector vec)`
Create a new vector by plussing another vector.
• #### minus

`public abstract Vector minus(Vector vec)`
Create a new vector by subtracting another vector.
• #### dot

`public abstract double dot(Vector vec)`
Compute the dot product with another vector.
• #### iterator

`public abstract VectorIterator iterator()`
Get the iterator of the vector.
• #### slice

`public abstract Vector slice(int[] indexes)`
Slice the vector.
• #### outer

`public abstract DenseMatrix outer()`
Compute the outer product with itself.
Returns:
The outer product matrix.