public class MatrixUtils extends Object
Constructor and Description |
---|
MatrixUtils() |
Modifier and Type | Method and Description |
---|---|
static double[][] |
abs(double[][] A)
absolute value
|
static double[][] |
add(double[][] A,
double v) |
static double[][] |
add(double[][] A,
double[][] B) |
static double[] |
addBias(double[] x) |
static double[][] |
addBias(double[][] M) |
static Jama.Matrix |
addBias(Jama.Matrix M) |
static double[][] |
copy(double[][] P)
Copy a 2D array
|
static int[][] |
deep_copy(int[][] M)
Deep Copy - Make a deep copy of M[][].
|
static double |
dot(double[] v,
double[] u)
dot product of two vectors
|
static double |
dsigma(double a)
Derivative of the sigmoid function applied to scalar
|
static double[] |
dsigma(double[] v)
Derivative of the sigmoid function applied to vector
|
static double[][] |
dsigma(double[][] A)
Derivative of the sigmoid function applied to Matrix
|
static Jama.Matrix |
dsigma(Jama.Matrix A)
Derivative of the sigmoid function applied to Jama Matrix
|
static void |
fillCol(double[][] M,
int k,
double val) |
static void |
fillRow(double[][] M,
int k,
double val) |
static double[] |
flatten(double[][] M)
Flatten - turn Matrix [0.
|
static int[] |
flatten(int[][] M)
Flatten - turn Matrix [0 1; 2 3] into vector [0 1 2 3].
|
static double[] |
getCol(double[][] M,
int k)
GetCol - return the k-th column of M (as a vector).
|
static int[] |
getCol(int[][] M,
int k)
GetCol - return the k-th column of M (as a vector).
|
static String |
getDim(double[][] M) |
static String |
getDim(Jama.Matrix M) |
static double[][] |
getTranspose(double[][] M) |
static weka.core.matrix.Matrix |
instancesToMatrix(weka.core.Instances inst)
Helper method that transforma an Instances object to a Matrix object.
|
static weka.core.Instances |
matrixToInstances(weka.core.matrix.Matrix mat,
weka.core.Instances patternInst)
Helper method that transforms a Matrix object to an Instances object.
|
static int[] |
maxIndices(double[][] M)
returns argmax_{j,k} M[j][k]
|
static double |
meanSquaredError(double[][] vectorBatch1,
double[][] vectorBatch2) |
static double[][] |
multiply(double[][] A,
double K)
Multiply - multiply each value in A[][] by constant K.
|
static double[][] |
multiply(double[][] A,
double[][] B)
Multiply - multiply matrices A and B together.
|
static double[] |
multiply(double[] a,
double[] b)
Multiply - multiply vectors a and b together.
|
static double[][] |
multiplyTranspose(double[][] A,
double[][] B) |
static double[] |
ones(int L)
Ones - return a vector full of 1s.
|
static void |
printDim(double[][] M) |
static void |
printDim(Jama.Matrix M) |
static void |
printMatrix(double[][] M_) |
static double[][] |
randn(int rows,
int cols,
Random r)
A 2D array of Gaussian random numbers
|
static Jama.Matrix |
randomn(int nrows,
int ncols,
Random r)
A matrix of Gaussian random numbers
|
static double[] |
removeBias(double[] x) |
static double[][] |
removeBias(double[][] M) |
static Jama.Matrix |
removeBias(Jama.Matrix M) |
static double[][] |
sample(double[][] M,
Random r)
Sample - Returns Matrix C where each value C[j][k] is 1 with probability M[j][k] and 0 otherwise.
|
static double[] |
sample(double[] v,
Random r)
Sample - Returns vector c where each value c[j][k] is 1 with probability v[j][k] and 0 otherwise.
|
static Jama.Matrix |
sample(Jama.Matrix M,
Random r)
Sample - Returns Matrix C where each value C[j][k] is 1 with probability M[j][k] and 0 otherwise.
|
static double |
sigma(double a)
Sigmoid / Logistic function
|
static double[] |
sigma(double[] v)
Sigmoid function applied to vector
|
static double[][] |
sigma(double[][] A)
Sigmoid function applied to matrix (2D array)
|
static Jama.Matrix |
sigma(Jama.Matrix A)
Sigmoid function applied to Matrix
|
static double |
squaredError(double[] vector1,
double[] vector2) |
static double |
SS(double[][] M)
squared sum
|
static double[][] |
subtract(double[][] A,
double[][] B) |
static double[] |
sum(double[][] M)
Sum - sum this matrix.
|
static int[] |
sum(int[][] M)
Sum - sum this matrix.
|
static double[][] |
threshold(double[][] P,
double t)
Threshold - apply threshold t to matrix P[][].
|
static double[][] |
threshold(double[][] P,
Random r)
sample from matrix
|
static double[] |
threshold(double[] v,
double t)
threshold function applied to vector
|
static Jama.Matrix |
threshold(Jama.Matrix M,
double t)
sigmoid function applied to vector
|
static String |
toString(double[][] M_)
ToString - return a String representation.
|
static String |
toString(double[][] M_,
int adp)
ToString - return a String representation (to adp decimal places).
|
static String |
toString(double[][] M,
String name)
ToString - return a String representation of 'M', in Matlab format, called 'name'.
|
static String |
toString(int[][] M_)
ToString - return a String representation.
|
static String |
toString(Jama.Matrix M) |
static double[][] |
transposeMultiply(double[][] A,
double[][] B) |
public static weka.core.matrix.Matrix instancesToMatrix(weka.core.Instances inst)
inst
- The Instances to transform.public static weka.core.Instances matrixToInstances(weka.core.matrix.Matrix mat, weka.core.Instances patternInst)
mat
- The Matrix to transform.patternInst
- the Instances template to usepublic static double[] getCol(double[][] M, int k)
public static int[] getCol(int[][] M, int k)
public static double[] addBias(double[] x)
public static double[][] addBias(double[][] M)
public static Jama.Matrix addBias(Jama.Matrix M)
public static double[] removeBias(double[] x)
public static Jama.Matrix removeBias(Jama.Matrix M)
public static double[][] removeBias(double[][] M)
public static double[][] multiply(double[][] A, double K)
public static String toString(Jama.Matrix M)
public static String toString(double[][] M_, int adp)
public static String toString(double[][] M_)
public static String toString(int[][] M_)
public static String toString(double[][] M, String name)
public static final double[][] threshold(double[][] P, double t)
public static int[] flatten(int[][] M)
public static double[] flatten(double[][] M)
public static double[][] subtract(double[][] A, double[][] B)
public static double[][] abs(double[][] A)
public static double SS(double[][] M)
public static final double sigma(double a)
public static final double[] sigma(double[] v)
public static final double[][] sigma(double[][] A)
public static final Jama.Matrix sigma(Jama.Matrix A)
public static final double dsigma(double a)
public static final double[] dsigma(double[] v)
public static final double[][] dsigma(double[][] A)
public static final Jama.Matrix dsigma(Jama.Matrix A)
public static int[][] deep_copy(int[][] M)
public static double[] ones(int L)
public static int[] sum(int[][] M)
public static double[] sum(double[][] M)
public static final void fillRow(double[][] M, int k, double val)
public static final void fillCol(double[][] M, int k, double val)
public static double[][] randn(int rows, int cols, Random r)
public static Jama.Matrix randomn(int nrows, int ncols, Random r)
public static final double[][] copy(double[][] P)
public static final double[][] threshold(double[][] P, Random r)
public static final double[] threshold(double[] v, double t)
public static final Jama.Matrix threshold(Jama.Matrix M, double t)
public static double[][] transposeMultiply(double[][] A, double[][] B)
public static double[][] multiplyTranspose(double[][] A, double[][] B)
public static double[][] multiply(double[][] A, double[][] B)
public static double[] multiply(double[] a, double[] b) throws Exception
Exception
public static double[][] getTranspose(double[][] M)
public static double[][] add(double[][] A, double[][] B)
public static double[][] add(double[][] A, double v)
public static double squaredError(double[] vector1, double[] vector2)
public static double meanSquaredError(double[][] vectorBatch1, double[][] vectorBatch2)
public static double dot(double[] v, double[] u)
public static double[][] sample(double[][] M, Random r)
public static double[] sample(double[] v, Random r)
public static Jama.Matrix sample(Jama.Matrix M, Random r)
public static void printMatrix(double[][] M_)
public static void printDim(Jama.Matrix M)
public static void printDim(double[][] M)
public static String getDim(double[][] M)
public static String getDim(Jama.Matrix M)
public static int[] maxIndices(double[][] M)
Copyright © 2017. All Rights Reserved.