code: public DenseMatrix getD() {
          int n = V.nrows();
          DenseMatrix D = Matrix.zeros(n, n);
          for (int i = 0; i < n; i++) {
              D.set(i, i, d[i]);
              if (e != null) {
                  if (e[i] > 0) {
                      D.set(i, i + 1, e[i]);
                  } else if (e[i] < 0) {
                      D.set(i, i - 1, e[i]);
                  }
              }
          }
          return D;
      }
docs: Returns the block diagonal eigenvalue matrix whose diagonal are the real
  part of eigenvalues, lower subdiagonal are positive imaginary parts, and
  upper subdiagonal are negative imaginary parts.