|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.wlu.cs.levy.SNARLI.SNMatrix
This class provides glue code for matrix 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 matrices.
Constructor Summary | |
SNMatrix(double[][] x)
Constructs a matrix using a 2D array of double-precision floating-point values. |
|
SNMatrix(int m,
int n)
Constructs a matrix of all zeros. |
Method Summary | |
void |
add(edu.wlu.cs.levy.SNARLI.SNMatrix a)
Adds a matrix to this matrix. |
static edu.wlu.cs.levy.SNARLI.SNMatrix |
arrayMultiply(edu.wlu.cs.levy.SNARLI.SNMatrix a,
edu.wlu.cs.levy.SNARLI.SNMatrix b)
Returns a matrix containing the products of the elements of two matrices. |
edu.wlu.cs.levy.SNARLI.SNMatrix |
copy()
Returns a deep copy of this matrix. |
void |
divide(double s)
Divides this matrix by a scalar. |
static edu.wlu.cs.levy.SNARLI.SNMatrix |
divide(edu.wlu.cs.levy.SNARLI.SNMatrix a,
double s)
Returns the quotient of a matrix and a scalar. |
static edu.wlu.cs.levy.SNARLI.SNMatrix |
gaussianNoise(int m,
int n,
java.util.Random r)
Returns a matrix of normally distributed random values. |
int |
getCols()
Returns the number of columns of this Matrix. |
edu.wlu.cs.levy.SNARLI.SNVector |
getRow(int i)
Gets the row vector at a certain index of this matrix. |
int |
getRows()
Returns the number of rows of this Matrix. |
double[][] |
getValues()
Returns a 2D array of the values contained in this matrix. |
double |
max()
Returns the value of the largest element of this matrix. |
edu.wlu.cs.levy.SNARLI.SNVector |
meanRows()
Returns a vector repsenting the mean over the rows of this Matrix. |
static edu.wlu.cs.levy.SNARLI.SNMatrix |
multiply(edu.wlu.cs.levy.SNARLI.SNMatrix a,
double s)
Returns the product of a matrix and a scalar. |
edu.wlu.cs.levy.SNARLI.SNVector |
multiply(edu.wlu.cs.levy.SNARLI.SNVector x)
Returns the product of this matrix and a vector. |
edu.wlu.cs.levy.SNARLI.SNMatrix |
ne(double s)
Returns a matrix containing ones where this matrix's elements are not equal to a scalar, and zeros elsewhere. |
void |
setRow(int i,
edu.wlu.cs.levy.SNARLI.SNVector x)
Sets the row vector at a certain index of this matrix. |
static edu.wlu.cs.levy.SNARLI.SNMatrix |
subtract(edu.wlu.cs.levy.SNARLI.SNMatrix a,
edu.wlu.cs.levy.SNARLI.SNMatrix b)
Returns the difference between two matrices. |
double |
sum()
Returns the sum over all elements of this Matrix. |
edu.wlu.cs.levy.SNARLI.SNVector |
sumRows()
Returns a vector representing the sum over the rows of this Matrix. |
java.lang.String |
toString()
Returns a String representation of this matrix. |
edu.wlu.cs.levy.SNARLI.SNMatrix |
transpose()
Returns the transpose of this matrix. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SNMatrix(int m, int n)
m
- number of rowsn
- number of columnspublic SNMatrix(double[][] x)
Method Detail |
public edu.wlu.cs.levy.SNARLI.SNVector meanRows()
public edu.wlu.cs.levy.SNARLI.SNVector sumRows()
public static edu.wlu.cs.levy.SNARLI.SNMatrix subtract(edu.wlu.cs.levy.SNARLI.SNMatrix a, edu.wlu.cs.levy.SNARLI.SNMatrix b)
a
- one matrixb
- the other matrix
java.lang.RuntimeException
- if the matrices have unequal sizespublic static edu.wlu.cs.levy.SNARLI.SNMatrix arrayMultiply(edu.wlu.cs.levy.SNARLI.SNMatrix a, edu.wlu.cs.levy.SNARLI.SNMatrix b)
a
- one matrixb
- the other matrix
java.lang.RuntimeException
- if the matrices have unequal sizespublic int getRows()
public int getCols()
public double[][] getValues()
public void setRow(int i, edu.wlu.cs.levy.SNARLI.SNVector x) throws java.lang.RuntimeException
i
- indexx
- vector
java.lang.RuntimeException
- if index is out of rangepublic edu.wlu.cs.levy.SNARLI.SNVector getRow(int i)
i
- index
java.lang.RuntimeException
- if index is out of rangepublic static edu.wlu.cs.levy.SNARLI.SNMatrix gaussianNoise(int m, int n, java.util.Random r)
m
- number of rowsn
- number of columns
public void add(edu.wlu.cs.levy.SNARLI.SNMatrix a) throws java.lang.RuntimeException
a
- the other matrix
java.lang.RuntimeException
- if the matrices have unequal sizespublic static edu.wlu.cs.levy.SNARLI.SNMatrix divide(edu.wlu.cs.levy.SNARLI.SNMatrix a, double s)
a
- the matrixs
- the scalar
public void divide(double s)
s
- the scalarpublic edu.wlu.cs.levy.SNARLI.SNMatrix transpose()
public static edu.wlu.cs.levy.SNARLI.SNMatrix multiply(edu.wlu.cs.levy.SNARLI.SNMatrix a, double s)
a
- the matrixs
- the scalar
public edu.wlu.cs.levy.SNARLI.SNVector multiply(edu.wlu.cs.levy.SNARLI.SNVector x)
x
- the vector
java.lang.RuntimeException
- if number of columns of this matrix does not
equal number of elements in xpublic double sum()
public double max()
public edu.wlu.cs.levy.SNARLI.SNMatrix copy()
public edu.wlu.cs.levy.SNARLI.SNMatrix ne(double s)
s
- the scalar
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 |