List of usage examples for org.apache.mahout.math.function Functions SQUARE
DoubleFunction SQUARE
To view the source code for org.apache.mahout.math.function Functions SQUARE.
Click Source Link
From source file:org.carrot2.matrix.factorization.IterativeMatrixFactorizationBase.java
License:Open Source License
/** * Orders U and V matrices according to the 'activity' of base vectors. *//*from ww w . j av a 2 s . c om*/ protected void order() { DoubleMatrix2D VT = V.viewDice(); aggregates = new double[VT.rows()]; for (int i = 0; i < aggregates.length; i++) { aggregates[i] = VT.viewRow(i).aggregate(Functions.PLUS, Functions.SQUARE); } final IndirectComparator.DescendingDoubleComparator comparator = new IndirectComparator.DescendingDoubleComparator( aggregates); V = MatrixUtils.sortedRowsView(VT, comparator).viewDice(); U = MatrixUtils.sortedRowsView(U.viewDice(), comparator).viewDice(); }
From source file:org.carrot2.matrix.MatrixUtils.java
License:Open Source License
/** * Calculates the Frobenius norm of a matrix. * // w ww . ja v a 2 s.c om * @see <a href="http://en.wikipedia.org/wiki/Matrix_norm#Frobenius_norm">Frobenius * norm</a> */ public static double frobeniusNorm(DoubleMatrix2D matrix) { return Math.sqrt(matrix.aggregate(Functions.PLUS, Functions.SQUARE)); }