/**
  * Computes the square-root of the weight matrix.
  *
  * @param m Symmetric, positive-definite (weight) matrix.
  * @return the square-root of the weight matrix.
  */
 private static RealMatrix squareRoot(final RealMatrix m) {
   if (m instanceof DiagonalMatrix) {
     final int dim = m.getRowDimension();
     final RealMatrix sqrtM = new DiagonalMatrix(dim);
     for (int i = 0; i < dim; i++) {
       sqrtM.setEntry(i, i, FastMath.sqrt(m.getEntry(i, i)));
     }
     return sqrtM;
   } else {
     final EigenDecomposition dec = new EigenDecomposition(m);
     return dec.getSquareRoot();
   }
 }