MatrixUtils { public static double computeOrthogonality(DoubleMatrix2D A) { double orthogonality = 0; DoubleMatrix2D cosines = A.zMult(A, null, 1, 0, true, false); for (int r = 0; r < cosines.rows(); r++) { for (int c = r + 1; c < cosines.columns(); c++) { orthogonality += cosines.getQuick(r, c); } } return orthogonality / ((cosines.rows() - 1) * cosines.rows() / 2.0); }  static DoubleMatrix2D normalizeColumnL2(DoubleMatrix2D A, double[] work); static DoubleMatrix2D normalizeSparseColumnL2(
      final DoubleMatrix2D A, final double[] work); static DoubleMatrix2D normalizeColumnL1(DoubleMatrix2D A, double[] work); static double computeOrthogonality(DoubleMatrix2D A); static double computeSparseness(DoubleMatrix2D A); static int[] minInColumns(DoubleMatrix2D A, int[] indices, double[] minValues); static int[] maxInColumns(DoubleMatrix2D A, int[] indices, double[] maxValues); static int[] maxInColumns(
      DoubleMatrix2D A, int[] indices, double[] maxValues, DoubleFunction transform); static int maxInRow(DoubleMatrix2D A, int row); static double[] sumRows(DoubleMatrix2D A, double[] sums); static double frobeniusNorm(DoubleMatrix2D matrix); static DoubleMatrix2D sortedRowsView(
      DoubleMatrix2D matrix, IndirectComparator comparator);  }
@Test public void testComputeOrthogonalityOrthogonal() { DoubleMatrix2D orthogonal = new DenseDoubleMatrix2D( new double[][] { {1.00, 0.00, 0.00, 0.00, 0.00}, {0.00, 1.00, 0.00, 0.00, 0.00}, {0.00, 0.00, 1.00, 0.00, 0.00}, {0.00, 0.00, 0.00, 1.00, 0.00}, {0.00, 0.00, 0.00, 0.00, 1.00} }); assertThat(MatrixUtils.computeOrthogonality(orthogonal)).isEqualTo(0.0, Offset.offset(0.00)); }
@Test public void testComputeOrthogonalityIdenticalColumns() { DoubleMatrix2D identical = new DenseDoubleMatrix2D( new double[][] { {0.00, 0.00, 0.00}, {0.49, 0.49, 0.49}, {0.49, 0.49, 0.49}, {0.72, 0.72, 0.72}, {0.00, 0.00, 0.00} }); assertThat(MatrixUtils.computeOrthogonality(identical)).isEqualTo(1.0, Offset.offset(0.02)); }