|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSTBB.MAT
This class provides many static methods for vector and matrix manipulation.
Method Summary | |
static double[] |
abs(double[] v)
returns absolute values componentwise. |
static double[][] |
abs(double[][] v)
Absolute value operation componentwise. |
static double[][] |
add(double[][] m1,
double m2)
add a constant to a matrix |
static double[][] |
add(double[][] m1,
double[][] m2)
Matrix addition |
static double[] |
add(double[] m1,
double m2)
add a constant to a vector |
static double[] |
add(double[] m1,
double[] m2)
vector addition |
static double[][] |
addDiagonals(double[][] m1,
double[] m2)
return a new matrix of m1 with m2 added onto its diagonals |
static double[] |
append(double[] a,
double b)
example: append({1,2,3},5)={1,2,3,5} |
static double[] |
copy(double[] v)
copy returns an exact replica of v. |
static double[][] |
copy(double[][] m)
copy returns an exact replica of m. |
static double |
correlation(double[] v1,
double[] v2)
compute correlation between v1 and v2. |
static double[][] |
diagonalMatrix(double[] v)
get a diagonal matrix with v[] as the diagonal elements |
static double[] |
divide(double[] m1,
double[] m2)
return m1/m2 componentwise |
static double[] |
dot(double[][] m1,
double[] v2)
Matrix-Vector multiplication m1.v2 |
static double[][] |
dot(double[][] m1,
double[][] m2)
Matrix multiplication m1.m2 |
static double |
dot(double[] v1,
double[] v2)
Vector dot product v1.v2 |
static double[] |
drop(double[] components,
int i)
Drop the first i number of components
i cannot be equal to the length of the vector. |
static double[] |
flatten(double[][] a)
example: flatten({{1,2,3},{4,5}}) = {1,2,3,4,5} |
static double |
generalDotProduct(double[] v1,
double[][] metric)
v1^T.metric.v1 assuming metric is a square matrix |
static double |
generalDotProduct(double[] v1,
double[][] metric,
double[] v2)
v1^T.metric.v2 |
static double[] |
getDiagonals(double[][] m)
get the diagonal elements from m |
static double[][] |
identityMatrix(int dim)
get an dim x dim identity matrix |
static double[] |
join(double[] a,
double[] b)
join two arrays into one. |
static double |
max(double[] data)
find the maximum value in an array. |
static double |
max(double[][] data)
find the maximum value in a double array |
static double |
max(double[][][] data)
find the maximum value in data. |
static double |
maxAbs(double[] v)
find the maximum value of the absolute values of an array. |
static double |
maxAbs(double[][] v)
find the max value of the absolute values of a double array. |
static double |
mean(double[] v)
get the mean value of vector v. |
static double |
min(double[] data)
find the minimum value is data. |
static double |
min(double[][] data)
find the minimum value in a matrix. |
static double |
min(double[][][] data)
find the minimum value in data. |
static double |
minAbs(double[] v)
find the minimum value of the absolute values of an array v. |
static double |
minAbs(double[][] v)
find the minimum value of the absolute values of a double array. |
static double[][] |
multiply(double[][] m1,
double m2)
Component-wise multiplication between a matrix and a number. |
static double[][] |
multiply(double[][] m1,
double[][] m2)
Component-wise multiplication between two matrices. |
static double[] |
multiply(double[] m1,
double m2)
Component-wise multiplication between a vector and a number. |
static double[] |
multiply(double[] m1,
double[] m2)
Component-wise multiplication between two vectors. |
static double |
norm(double[] v)
vector norm |
static double |
norm(double[][] m)
Frobenius norm |
static double[] |
normalize(double[] v)
Obtain a normalized vector from v |
static double[] |
ones(int num)
get an array of one's with length num |
static double[][] |
ones(int ro,
int co)
get a matrix of one's with dimensions ro x co |
static double[][] |
outerProduct(double[] v1,
double[] v2)
outer product of two vectors. |
static double[] |
prepend(double[] a,
double b)
example: prepend({1,2,3},5)={5,1,2,3} |
static double[] |
random(int N)
an array of N uniform random values ranging from -1.0 to 1.0); |
static double[] |
random(int N,
double a,
double b)
an array of N uniform random numbers ranging from a to b (a < b); |
static double[][] |
removeDiagonals(double[][] mat)
set the diagonal elements of mat to zero. |
static double[] |
removeMean(double[] v)
Obtain a vector with zero mean |
static double[][] |
setDiagonals(double[][] m1,
double[] m2)
return a new matrix of m1 where the diagonal elements of m1 have been replaced by m2. |
static void |
setValue(double[][] m,
double v1)
set m[i][j] = v1 for all i,j. |
static void |
setValue(double[] v,
double v1)
set v[i] = v1 for all i. |
static double[][] |
sortColumns(double[][] mat,
int[] indexArray)
return a matrix where the columns of the matrix is sorted according to the index array. |
static double[][] |
sortRows(double[][] mat,
int[] indexArray)
sort rows |
static double[] |
square(double[] v)
square the components |
static double |
standardDeviation(double[] v)
sample standard deviation returns 0 if v.length==1. |
static double[][] |
subtract(double[][] m1,
double m2)
return m1 - m2 |
static double[][] |
subtract(double[][] m1,
double[][] m2)
return m1 - m2 |
static double[] |
subtract(double[] m1,
double m2)
return m1 - m2 |
static double[] |
subtract(double[] m1,
double[] m2)
return m1 - m2 |
static double |
sum(double[] v)
get the sum of all the elements of v using Kahan summation. |
static double |
sumOfSquares(double[] v)
return v[0]*v[0]+...+v[n-1][n-1] where n is the length of v |
static double[] |
take(double[] components,
int i)
Take the first i number of components
i can be equal to the length of the vector. |
static java.lang.String |
toString(double[] a)
This method is for printing out elements of a on the screen. |
static java.lang.String |
toString(double[][] a)
This method is for printing out elements of a on the screen. |
static java.lang.String |
toString(int[] a)
This method is for printing out elements of a on the screen. |
static java.lang.String |
toString(int[][] a)
This method is for printing out elements of a on the screen. |
static double |
trace(double[][] m)
get the sum of the diagonal elements of m |
static double[][] |
transpose(double[][] m)
matrix transposition |
static double |
variance(double[] v)
compute sample variance returns 0 if v.length==1. |
static double[] |
zeroes(int num)
get an array of zero's with length num |
static double[][] |
zeroes(int ro,
int co)
get a matrix of zero's with dimensions ro x co |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static double[] abs(double[] v)
public static double[] random(int N, double a, double b)
Assumption: N>0 and (a
public static double[] random(int N)
public static double[][] abs(double[][] v)
public static double[][] removeDiagonals(double[][] mat)
public static void setValue(double[] v, double v1)
public static void setValue(double[][] m, double v1)
public static double[][] addDiagonals(double[][] m1, double[] m2)
public static double[][] setDiagonals(double[][] m1, double[] m2)
public static double[] add(double[] m1, double m2)
public static double[] add(double[] m1, double[] m2)
public static double[][] add(double[][] m1, double m2)
public static double[][] add(double[][] m1, double[][] m2)
public static double[] divide(double[] m1, double[] m2)
m1
- type double[]m2
- type double[]public static double[] subtract(double[] m1, double m2)
m1
- type double[]m2
- type doublepublic static double[] subtract(double[] m1, double[] m2)
m1
- type double[]m2
- type double[]public static double[][] subtract(double[][] m1, double m2)
m1
- type double[][]m2
- type doublepublic static double[][] subtract(double[][] m1, double[][] m2)
m1
- type double[][]m2
- type double[][]public static double[] multiply(double[] m1, double m2)
public static double[] multiply(double[] m1, double[] m2)
public static double[][] multiply(double[][] m1, double m2)
public static double[][] multiply(double[][] m1, double[][] m2)
public static double[][] dot(double[][] m1, double[][] m2)
public static double[] dot(double[][] m1, double[] v2)
public static double dot(double[] v1, double[] v2)
public static double[] ones(int num)
public static double[] zeroes(int num)
public static double[][] ones(int ro, int co)
public static double[][] zeroes(int ro, int co)
public static double[][] identityMatrix(int dim)
public static double[][] diagonalMatrix(double[] v)
public static double[] getDiagonals(double[][] m)
public static double trace(double[][] m)
public static double[][] transpose(double[][] m)
public static double generalDotProduct(double[] v1, double[][] metric, double[] v2)
public static double generalDotProduct(double[] v1, double[][] metric)
public static double max(double[] data)
public static double max(double[][] data)
public static double max(double[][][] data)
public static double min(double[] data)
public static double min(double[][] data)
public static double min(double[][][] data)
public static double sum(double[] v)
public static double[] join(double[] a, double[] b)
join two arrays into one.
Example: a={1,2,3}; b={4,5};
join(a,b) returns {1,2,3,4,5};
public static double[] prepend(double[] a, double b)
public static double[] append(double[] a, double b)
public static double[][] outerProduct(double[] v1, double[] v2)
returns v1.v2^T
public static double[] flatten(double[][] a)
public static double norm(double[][] m)
public static double norm(double[] v)
public static double sumOfSquares(double[] v)
public static double mean(double[] v)
public static double[] normalize(double[] v)
public static double[] removeMean(double[] v)
public static double correlation(double[] v1, double[] v2)
public static double[] take(double[] components, int i)
i
number of components
i
can be equal to the length of the vector.
If i
is negative then this method gives
the last i
elements of vector
public static double[] drop(double[] components, int i)
i
number of components
i
cannot be equal to the length of the vector.
If i
is negative then this method drop
the last i
elements of vector
public static double[] square(double[] v)
returns {v[0]*v[0], v[1]*v[1], ... }
public static double variance(double[] v)
public static double standardDeviation(double[] v)
public static double[] copy(double[] v)
public static double[][] copy(double[][] m)
public static java.lang.String toString(double[][] a)
public static java.lang.String toString(int[][] a)
public static java.lang.String toString(double[] a)
public static java.lang.String toString(int[] a)
public static double[][] sortColumns(double[][] mat, int[] indexArray)
Notice that the return type is double[][].
public static double[][] sortRows(double[][] mat, int[] indexArray)
public static double minAbs(double[] v)
public static double maxAbs(double[] v)
public static double minAbs(double[][] v)
public static double maxAbs(double[][] v)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |