|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.wlu.cs.levy.SNARLI.SNVector
This class provides glue code for vector operations in SNARLI. You do not need to call any of these methods to use SNARLI. This class is provided to show you the methods you need to implement if you want to use a different implementation for vectors.
Constructor Summary | |
SNVector(double[] a)
Constructs a vector using a 1D array of double-precision floating-point values. |
|
SNVector(int n)
Constructs a vector of all zeros. |
Method Summary | |
void |
add(double s)
Adds a scalar to this vector. |
void |
add(edu.wlu.cs.levy.SNARLI.SNVector x)
Adds a vector to this vector. |
static edu.wlu.cs.levy.SNARLI.SNVector |
add(edu.wlu.cs.levy.SNARLI.SNVector x,
double s)
Returns the sum of a vector and a scalar. |
static edu.wlu.cs.levy.SNARLI.SNVector |
add(edu.wlu.cs.levy.SNARLI.SNVector x,
edu.wlu.cs.levy.SNARLI.SNVector y)
Returns the sum of two vectors. |
edu.wlu.cs.levy.SNARLI.SNVector |
and(edu.wlu.cs.levy.SNARLI.SNVector x)
Returns the logical AND of this vector with another. |
void |
arrayMultiply(edu.wlu.cs.levy.SNARLI.SNVector x)
Multiplies the elements of this vector by those of another. |
static edu.wlu.cs.levy.SNARLI.SNVector |
arrayMultiply(edu.wlu.cs.levy.SNARLI.SNVector x,
edu.wlu.cs.levy.SNARLI.SNVector y)
Returns a vector containing the products of the elements of two vectors. |
edu.wlu.cs.levy.SNARLI.SNVector |
copy()
Returns a deep copy of this vector. |
void |
divide(double s)
Divides this vector by a scalar. |
static edu.wlu.cs.levy.SNARLI.SNVector |
divide(edu.wlu.cs.levy.SNARLI.SNVector x,
double s)
Returns the quotient of a vector and a scalar. |
double |
eucDist(edu.wlu.cs.levy.SNARLI.SNVector x)
Returns the Euclidean distance between this vector and another. |
int[] |
find(double s)
Returns indices where vector equals scalar argument. |
static edu.wlu.cs.levy.SNARLI.SNVector |
gaussianNoise(int n,
java.util.Random r)
Returns a vector of normally distributed random values. |
edu.wlu.cs.levy.SNARLI.SNVector |
ge(double s)
Returns a vector containing ones where this vector's elements are greater than or equal to a scalar, and zeros elsewhere. |
double |
getValue(int i)
Returns an indexed value from this vector. |
double[] |
getValues()
Returns a 1D array of the values contained in this vector. |
edu.wlu.cs.levy.SNARLI.SNVector |
le(double s)
Returns a vector containing ones where this vector's elements are less than or equal to a scalar, and zeros elsewhere. |
int |
length()
Returns the length of this vector. |
double |
max()
Returns the largest value of any element in this vector. |
double |
min()
Returns the value of the smallest element of this vector. |
void |
multiply(double s)
Multiplies this vector by a scalar. |
edu.wlu.cs.levy.SNARLI.SNVector |
multiply(edu.wlu.cs.levy.SNARLI.SNMatrix a)
Returns the product of this Vector and a Matrix. |
void |
multiply(edu.wlu.cs.levy.SNARLI.SNVector x)
Multiplies the elements of this vector by those of another vector. |
static edu.wlu.cs.levy.SNARLI.SNVector |
multiply(edu.wlu.cs.levy.SNARLI.SNVector x,
double s)
Returns the product of a vector and a scalar. |
edu.wlu.cs.levy.SNARLI.SNVector |
ne(double s)
Returns a vector containing ones where this vector's elements are not equal to a scalar, and zeros elsewhere. |
double |
nycDist(edu.wlu.cs.levy.SNARLI.SNVector x)
Returns the Manhattan distance (L1 norm of differences) between this vector and another. |
edu.wlu.cs.levy.SNARLI.SNMatrix |
outer(edu.wlu.cs.levy.SNARLI.SNVector x)
Returns the outer product of this vector and another. |
edu.wlu.cs.levy.SNARLI.SNMatrix |
repmat(int m)
Replicates this vector as a matrix. |
void |
setAll(double s)
Sets all entries to a scalar. |
void |
setValue(int i,
double s)
Sets an entry to a scalar at a certain index. |
edu.wlu.cs.levy.SNARLI.SNVector |
sort()
Returns a copy of this vector, sorted in ascending order. |
void |
subtract(double s)
Subtracts a scalar from this vector. |
void |
subtract(edu.wlu.cs.levy.SNARLI.SNVector x)
Subtracts a vector from this vector. |
static edu.wlu.cs.levy.SNARLI.SNVector |
subtract(edu.wlu.cs.levy.SNARLI.SNVector x,
double s)
Returns the difference between a vector and a scalar. |
static edu.wlu.cs.levy.SNARLI.SNVector |
subtract(edu.wlu.cs.levy.SNARLI.SNVector x,
edu.wlu.cs.levy.SNARLI.SNVector y)
Returns the difference between two vectors. |
double |
sum()
Returns the sum of the elements of this vector. |
java.lang.String |
toString()
Returns a String representation of this vector. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SNVector(int n)
n
- vector lengthpublic SNVector(double[] a)
a
- the array of valuesMethod Detail |
public int length()
public double getValue(int i) throws java.lang.RuntimeException
i
- the index
java.lang.RuntimeException
- if i is out of range [0, length-1]public void add(double s)
s
- the scalarpublic void subtract(double s)
s
- the scalarpublic void multiply(double s)
s
- the scalarpublic void divide(double s)
s
- the scalarpublic static edu.wlu.cs.levy.SNARLI.SNVector add(edu.wlu.cs.levy.SNARLI.SNVector x, double s)
x
- the vectors
- the scalar
public static edu.wlu.cs.levy.SNARLI.SNVector subtract(edu.wlu.cs.levy.SNARLI.SNVector x, double s)
x
- the vectors
- the scalar
public static edu.wlu.cs.levy.SNARLI.SNVector multiply(edu.wlu.cs.levy.SNARLI.SNVector x, double s)
x
- the vectors
- the scalar
public static edu.wlu.cs.levy.SNARLI.SNVector divide(edu.wlu.cs.levy.SNARLI.SNVector x, double s)
x
- the vectors
- the scalar
public void add(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic void subtract(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic void multiply(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic static edu.wlu.cs.levy.SNARLI.SNVector add(edu.wlu.cs.levy.SNARLI.SNVector x, edu.wlu.cs.levy.SNARLI.SNVector y) throws java.lang.RuntimeException
x
- one vectory
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic static edu.wlu.cs.levy.SNARLI.SNVector subtract(edu.wlu.cs.levy.SNARLI.SNVector x, edu.wlu.cs.levy.SNARLI.SNVector y) throws java.lang.RuntimeException
x
- one vectory
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic static edu.wlu.cs.levy.SNARLI.SNVector arrayMultiply(edu.wlu.cs.levy.SNARLI.SNVector x, edu.wlu.cs.levy.SNARLI.SNVector y) throws java.lang.RuntimeException
x
- one vectory
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic void arrayMultiply(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic double[] getValues()
public double sum()
public double min()
public double eucDist(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic edu.wlu.cs.levy.SNARLI.SNMatrix repmat(int m)
m
- number of times to replicate
public edu.wlu.cs.levy.SNARLI.SNVector sort()
public int[] find(double s)
public double nycDist(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if Vectors have unequal lengthspublic static edu.wlu.cs.levy.SNARLI.SNVector gaussianNoise(int n, java.util.Random r)
public edu.wlu.cs.levy.SNARLI.SNMatrix outer(edu.wlu.cs.levy.SNARLI.SNVector x)
x
- the other vector
java.lang.RuntimeException
- if the other vector is nullpublic edu.wlu.cs.levy.SNARLI.SNVector copy()
public void setAll(double s)
s
- the scalarpublic void setValue(int i, double s) throws java.lang.RuntimeException
i
- indexs
- scalar
java.lang.RuntimeException
- if the index is invalidepublic edu.wlu.cs.levy.SNARLI.SNVector ne(double s)
s
- the scalar
public edu.wlu.cs.levy.SNARLI.SNVector ge(double s)
s
- the scalar
public edu.wlu.cs.levy.SNARLI.SNVector le(double s)
s
- the scalar
public double max()
public edu.wlu.cs.levy.SNARLI.SNVector and(edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
x
- the other vector
java.lang.RuntimeException
- if the vectors have unequal lengthspublic edu.wlu.cs.levy.SNARLI.SNVector multiply(edu.wlu.cs.levy.SNARLI.SNMatrix a) throws java.lang.RuntimeException
a
- the matrix
InvalidOperationException
- if the matrix is null
InvalidOperationException
- if the inner dimensions mismatch
java.lang.RuntimeException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |