/** * Apply the transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public double[] apply(double[] v) { return unhomogeneVector(times(trans, homogeneVector(v))); }
/** * Apply the inverse transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public double[] applyInverse(double[] v) { if(inv == null) { updateInverse(); } return unhomogeneVector(times(inv, homogeneVector(v))); }
/** * Solve A*X = b * * @param b right hand side * @return solution if A is square, least squares solution otherwise */ public static double[] solve(double[][] A, double[] b) { final int rows = A.length, cols = A[0].length; return rows == cols // ? (new LUDecomposition(A, rows, cols)).solve(b) // : (new QRDecomposition(A, rows, cols)).solve(b); }
/** * Apply the transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public double[] applyRelative(double[] v) { return unhomogeneRelativeVector(times(trans, homogeneRelativeVector(v))); }
/** * Matrix inverse or pseudoinverse * * @param A matrix to invert * @return inverse(A) if A is square, pseudoinverse otherwise. */ public static double[][] inverse(double[][] A) { final int rows = A.length, cols = A[0].length; return rows == cols // ? (new LUDecomposition(A, rows, cols)).inverse() // : (new QRDecomposition(A, rows, cols)).inverse(); }
/** * Add a single value with weight 1.0. * * @param val Value */ public final void put(Vector val) { put(val.getArrayRef()); }
/** * Compute the Mahalanobis distance from the centroid for a given vector. * * @param vec Vector * @return Mahalanobis distance */ public double mahalanobisDistance(Vector vec) { if(invCovMatr != null) { return VMath.mahalanobisDistance(invCovMatr.getArrayRef(), vec.getArrayRef(), mref); } Vector difference = vec.minus(mean); return difference.transposeTimes(difference); }
/** * Apply the transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public Vector applyRelative(Vector v) { return unhomogeneRelativeVector(trans.times(homogeneRelativeVector(v))); }
/** * Add a single value with weight 1.0. * * @param val Value */ public final void put(Vector val) { put(val.getArrayRef()); }
/** * Find the inverse matrix. * * @return Inverse matrix * @throws ArithmeticException Matrix is rank deficient. */ public double[][] inverse() { return solveInplace(unitMatrix(m)); } }
@Override public void beginEStep() { if(covariance == null) { covariance = new Matrix(mean.getDimensionality(), mean.getDimensionality()); return; } wsum = 0.; }
/** * Apply the inverse transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public double[] applyInverse(double[] v) { if(inv == null) { updateInverse(); } return unhomogeneVector(VMath.times(inv.elements, homogeneVector(v))); }
/** * Solve A*X = B * * @param B right hand side * @return solution if A is square, least squares solution otherwise */ public static double[][] solve(double[][] A, double[][] B) { final int rows = A.length, cols = A[0].length; return rows == cols // ? (new LUDecomposition(A, rows, cols)).solve(B) // : (new QRDecomposition(A, rows, cols)).solve(B); }
/** * Apply the transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public double[] apply(double[] v) { return unhomogeneVector(VMath.times(trans.elements, homogeneVector(v))); }
/** * Apply the transformation onto a vector * * @param v vector of dimensionality dim * @return transformed vector of dimensionality dim */ public double[] applyRelative(double[] v) { return unhomogeneRelativeVector(VMath.times(trans.elements, homogeneRelativeVector(v))); }
/** * Matrix inverse or pseudoinverse * * @param A matrix to invert * @return inverse(A) if A is square, pseudoinverse otherwise. */ public static double[][] inverse(double[][] A) { final int rows = A.length, cols = A[0].length; return rows == cols // ? (new LUDecomposition(A, rows, cols)).inverse() // : (new QRDecomposition(A, rows, cols)).inverse(); }
/** * Add data with a given weight. * * @param val data * @param weight weight */ public final void put(Vector val, double weight) { put(val.getArrayRef(), weight); }
/** * Find the inverse matrix. * * @return Inverse matrix * @throws ArithmeticException Matrix is rank deficient. */ public double[][] inverse() { return solveInplace(unitMatrix(m)); } }
/** * Solve A*X = B * * @param B right hand side * @return solution if A is square, least squares solution otherwise */ public final Matrix solve(final Matrix B) { return (elements.length == columndimension ? (new LUDecomposition(this)).solve(B) : (new QRDecomposition(this)).solve(B)); }