public class SimpleVector
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
SimpleVector.VectorNormType |
Constructor and Description |
---|
SimpleVector()
Creates a null vector.
|
SimpleVector(double... otherBuffer)
Creates a new vector initialized by an ordered list of numbers
|
SimpleVector(int len)
Creates a len dimensional vector
|
SimpleVector(Jama.Matrix other)
Creates a new vector from a jama equivalent
|
SimpleVector(SimpleVector otherVec)
Creates a new vector from otherVec.
|
SimpleVector(java.lang.String str)
Creates a new vector from a string equivalent
|
Modifier and Type | Method and Description |
---|---|
void |
absolute() |
SimpleVector |
absoluted() |
void |
add(double addend)
Method to add a scalar to this vector in place.
|
void |
add(SimpleVector... addends)
Method to add other vectors to this vector in place.
|
void |
addToElement(int i,
double addend) |
SimpleVector |
clone() |
double[] |
copyAsDoubleArray()
Copies the elements of this vector to a double array
|
void |
copyTo(double[] other)
Copies the element of this vector to the double array provided
|
void |
divideBy(double divisor) |
SimpleVector |
dividedBy(double divisor)
Returns a scaled instance of the vector.
|
void |
divideElementBy(int i,
double divisor) |
void |
divideElementWiseBy(SimpleVector... divisors) |
void |
fill(double value)
Sets all entries to the given value.
|
double |
getElement(int i)
Retrieve vector element at index i
|
int |
getLen() |
SimpleVector |
getSubVec(int firstInd,
int size) |
java.lang.String |
getVectorSerialization() |
void |
init(double... otherBuffer)
Initialize vector with a comma-separated list of double array
|
void |
init(int len)
Initialize vector to [0,0,...,0] and length len.
|
void |
init(SimpleVector otherVec)
Initialize vector with otherVec
|
void |
init(java.lang.String str)
Initialize vector with string equivalent
|
double |
max() |
double |
min() |
SimpleVector |
multipliedBy(double factor)
Returns a scaled instance of the vector.
|
void |
multiplyBy(double factor) |
void |
multiplyElementBy(int i,
double factor) |
void |
multiplyElementWiseBy(SimpleVector... factors) |
void |
negate() |
SimpleVector |
negated() |
double |
norm(SimpleVector.VectorNormType normType) |
SimpleVector |
normalizedL2() |
void |
normalizeL2() |
double |
normL2() |
void |
ones()
Sets all entries to 1.0.
|
void |
randomize(double min,
double max)
Assigns random values to the entries of the vector.
|
void |
setElementValue(int i,
double val)
Replaces the vector element at index i
|
void |
setSubVecValue(int firstInd,
SimpleVector subVector) |
void |
setVectorSerialization(java.lang.String str) |
void |
subtract(double subtrahend) |
void |
subtract(SimpleVector... subtrahends) |
void |
subtractFromElement(int i,
double subtrahend) |
java.lang.String |
toString() |
SimpleMatrix |
transposed() |
void |
zeros()
Sets all entries to 0.0.
|
public SimpleVector()
public SimpleVector(int len)
len
- is dimension of vector.public SimpleVector(SimpleVector otherVec)
otherVec
- public SimpleVector(double... otherBuffer)
otherBuffer
- public SimpleVector(java.lang.String str)
str
- public SimpleVector(Jama.Matrix other)
other
- public void init(int len)
len
- is dimension of vectorpublic void init(SimpleVector otherVec)
otherVec
- public void init(double... otherBuffer)
otherBuffer
- public void init(java.lang.String str)
str
- public SimpleVector clone()
clone
in class java.lang.Object
public double[] copyAsDoubleArray()
public void copyTo(double[] other)
other
- is array to be populatedpublic int getLen()
public void fill(double value)
public void zeros()
public void ones()
public void randomize(double min, double max)
min
- The lower bound of the interval the values are drawn from.max
- The upper bound of the interval the values are drawn from. Note that value max
itself is excluded from the interval and therefore never assigned.public double getElement(int i)
i
- index to be retrievedpublic void setElementValue(int i, double val)
i
- index to be replacedval
- is new valuepublic SimpleVector getSubVec(int firstInd, int size)
public void setSubVecValue(int firstInd, SimpleVector subVector)
public void addToElement(int i, double addend)
public void subtractFromElement(int i, double subtrahend)
public void multiplyElementBy(int i, double factor)
public void divideElementBy(int i, double divisor)
public void add(double addend)
addend
- the other vectorpublic void subtract(double subtrahend)
public void multiplyBy(double factor)
public SimpleVector multipliedBy(double factor)
factor
- the scalarpublic void divideBy(double divisor)
public SimpleVector dividedBy(double divisor)
divisor
- the scalarpublic void add(SimpleVector... addends)
addends
- The other vectors.public void subtract(SimpleVector... subtrahends)
public void multiplyElementWiseBy(SimpleVector... factors)
public void divideElementWiseBy(SimpleVector... divisors)
public void negate()
public SimpleVector negated()
public void absolute()
public SimpleVector absoluted()
public double min()
public double max()
public SimpleMatrix transposed()
public double norm(SimpleVector.VectorNormType normType)
public double normL2()
public void normalizeL2()
public SimpleVector normalizedL2()
public java.lang.String getVectorSerialization()
public void setVectorSerialization(java.lang.String str)
public java.lang.String toString()
toString
in class java.lang.Object