code: public double[][] solve(double[][] B) {
  
          if (B.length != n) {
              throw new IllegalArgumentException("Matrix row dimensions must agree.");
          }
          if (!isspd) {
              throw new RuntimeException("Matrix is not symmetric positive definite.");
          }
  
          // Copy right hand side.
          double[][] X = Matrix.Copy(B);
          int nx = B[0].length;
  
          // Solve L*Y = B;
          for (int k = 0; k < n; k++) {
              for (int j = 0; j < nx; j++) {
                  for (int i = 0; i < k; i++) {
                      X[k][j] -= X[i][j] * L[k][i];
                  }
                  X[k][j] /= L[k][k];
              }
          }
  
          // Solve L'*X = Y;
          for (int k = n - 1; k >= 0; k--) {
              for (int j = 0; j < nx; j++) {
                  for (int i = k + 1; i < n; i++) {
                      X[k][j] -= X[i][j] * L[i][k];
                  }
                  X[k][j] /= L[k][k];
              }
          }
  
          return Matrix.SubMatrix(X, n, nx);
      }
docs: Solve A*X = B
  
  @param B A Matrix with as many rows as A and any number of columns.
  @return X so that L*L'*X = B
  @throws IllegalArgumentException Matrix row dimensions must agree.
  @throws RuntimeException         Matrix is not symmetric positive definite.