hex.util

## Class LinearAlgebraUtils

• java.lang.Object
• hex.util.LinearAlgebraUtils

• public class LinearAlgebraUtils
extends java.lang.Object
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  LinearAlgebraUtils.BMulInPlaceTask
Computes B = XY where X is n by k and Y is k by p, saving result in same frame Input: [X,B] (large frame) passed to doAll, where we write to B yt = Y' = transpose of Y (small matrix) ncolX = number of columns in X
static class  LinearAlgebraUtils.BMulTask
Computes B = XY where X is n by k and Y is k by p, saving result in new vecs Input: dinfo = X (large frame) with dinfo._adaptedFrame passed to doAll yt = Y' = transpose of Y (small matrix) Output: XY (large frame) is n by p
static class  LinearAlgebraUtils.BMulTaskMatrices
Compute B = XY where where X is n by k and Y is k by p and they are both stored as Frames.
static class  LinearAlgebraUtils.CopyQtoQMatrix
static class  LinearAlgebraUtils.FindMaxIndex
static class  LinearAlgebraUtils.ForwardSolve
Given lower triangular L, solve for Q in QL' = A (LQ' = A') using forward substitution Dimensions: A is n by p, Q is n by p, R = L' is p by p Input: [A,Q] (large frame) passed to doAll, where we write to Q
static class  LinearAlgebraUtils.ForwardSolveInPlace
Given lower triangular L, solve for Q in QL' = A (LQ' = A') using forward substitution Dimensions: A is n by p, Q is n by p, R = L' is p by p Input: A (large frame) passed to doAll, where we overwrite each row of A with its row of Q
static class  LinearAlgebraUtils.SMulTask
Computes A'Q where A is n by p and Q is n by k Input: [A,Q] (large frame) passed to doAll Output: atq = A'Q (small matrix) is \tilde{p} by k where \tilde{p} = number of cols in A with categoricals expanded
• ### Field Summary

Fields
Modifier and Type Field and Description
static hex.ToEigenVec toEigen
• ### Constructor Summary

Constructors
Constructor and Description
LinearAlgebraUtils()
• ### Method Summary

All Methods
Modifier and Type Method and Description
static double[] backwardSolve(double[][] L, double[] b, double[] res)
static double[][] chol2Inv(double[][] cholR)
Given the cholesky decomposition of X = QR, this method will return the inverse of transpose(X)*X by attempting to solve for transpose(R)*R*XTX_inverse = Identity matrix
static double[][] computeQ(water.Key<water.Job> jobKey, DataInfo yinfo, water.fvec.Frame ywfrm)
static double computeQ(water.Key<water.Job> jobKey, DataInfo yinfo, water.fvec.Frame ywfrm, double[][] xx)
Solve for Q from Y = QR factorization and write into new frame
static double[][] computeQInPlace(water.Key<water.Job> jobKey, DataInfo yinfo)
Solve for Q from Y = QR factorization and write into Y frame
static double[][] computeR(water.Key<water.Job> jobKey, DataInfo yinfo, boolean transpose)
Get R = L' from Cholesky decomposition Y'Y = LL' (same as R from Y = QR)
static EigenPair[] createReverseSortedEigenpairs(double[] eigenvalues, double[][] eigenvectors)
static EigenPair[] createSortedEigenpairs(double[] eigenvalues, double[][] eigenvectors)
static double[] expandRow(double[] row, DataInfo dinfo, double[] tmp, boolean modify_numeric)
static double[] extractEigenvaluesFromEigenpairs(EigenPair[] eigenPairs)
static double[][] extractEigenvectorsFromEigenpairs(EigenPair[] eigenPairs)
static double[] forwardSolve(double[][] L, double[] b)
static java.lang.String getMatrixInString(double[][] matrix)
static double[][] matrixMultiply(double[][] A, double[][] B)
static int numColsExp(water.fvec.Frame fr, boolean useAllFactorLevels)
Number of columns with categoricals expanded.
static double[][] reshape1DArray(double[] arr, int m, int n)
static double[] sqrtDiag(double[][] aMat)
Given a matrix aMat as a double [][] array, this function will return an array that is the square root of the diagonals of aMat.
static water.fvec.Vec toEigen(water.fvec.Vec src)
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Field Detail

• #### toEigen

public static hex.ToEigenVec toEigen
• ### Constructor Detail

• #### LinearAlgebraUtils

public LinearAlgebraUtils()
• ### Method Detail

• #### forwardSolve

public static double[] forwardSolve(double[][] L,
double[] b)
• #### sqrtDiag

public static double[] sqrtDiag(double[][] aMat)
Given a matrix aMat as a double [][] array, this function will return an array that is the square root of the diagonals of aMat. Note that the first index is column and the second index is row.
Parameters:
aMat -
Returns:
• #### chol2Inv

public static double[][] chol2Inv(double[][] cholR)
Given the cholesky decomposition of X = QR, this method will return the inverse of transpose(X)*X by attempting to solve for transpose(R)*R*XTX_inverse = Identity matrix
Parameters:
cholR -
Returns:
• #### matrixMultiply

public static double[][] matrixMultiply(double[][] A,
double[][] B)
• #### backwardSolve

public static double[] backwardSolve(double[][] L,
double[] b,
double[] res)
• #### expandRow

public static double[] expandRow(double[] row,
DataInfo dinfo,
double[] tmp,
boolean modify_numeric)
• #### reshape1DArray

public static double[][] reshape1DArray(double[] arr,
int m,
int n)
• #### createSortedEigenpairs

public static EigenPair[] createSortedEigenpairs(double[] eigenvalues,
double[][] eigenvectors)
• #### createReverseSortedEigenpairs

public static EigenPair[] createReverseSortedEigenpairs(double[] eigenvalues,
double[][] eigenvectors)
• #### extractEigenvaluesFromEigenpairs

public static double[] extractEigenvaluesFromEigenpairs(EigenPair[] eigenPairs)
• #### extractEigenvectorsFromEigenpairs

public static double[][] extractEigenvectorsFromEigenpairs(EigenPair[] eigenPairs)
• #### computeR

public static double[][] computeR(water.Key<water.Job> jobKey,
DataInfo yinfo,
boolean transpose)
Get R = L' from Cholesky decomposition Y'Y = LL' (same as R from Y = QR)
Parameters:
jobKey - Job key for Gram calculation
yinfo - DataInfo for Y matrix
transpose - Should result be transposed to get L?
Returns:
L or R matrix from Cholesky of Y Gram
• #### computeQ

public static double computeQ(water.Key<water.Job> jobKey,
DataInfo yinfo,
water.fvec.Frame ywfrm,
double[][] xx)
Solve for Q from Y = QR factorization and write into new frame
Parameters:
jobKey - Job key for Gram calculation
yinfo - DataInfo for Y matrix
ywfrm - Input frame [Y,W] where we write into W
Returns:
l2 norm of Q - W, where W is old matrix in frame, Q is computed factorization
• #### computeQ

public static double[][] computeQ(water.Key<water.Job> jobKey,
DataInfo yinfo,
water.fvec.Frame ywfrm)
• #### computeQInPlace

public static double[][] computeQInPlace(water.Key<water.Job> jobKey,
DataInfo yinfo)
Solve for Q from Y = QR factorization and write into Y frame
Parameters:
jobKey - Job key for Gram calculation
yinfo - DataInfo for Y matrix
• #### numColsExp

public static int numColsExp(water.fvec.Frame fr,
boolean useAllFactorLevels)
Number of columns with categoricals expanded.
Returns:
Number of columns with categoricals expanded into indicator columns
• #### toEigen

public static water.fvec.Vec toEigen(water.fvec.Vec src)
• #### getMatrixInString

public static java.lang.String getMatrixInString(double[][] matrix)