Here you can find the source of invertUpperTriangular(double[][] r)
public static double[][] invertUpperTriangular(double[][] r)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w.j a v a2s . co m * Uses backward substitution to invert an upper triangular matrix. */ public static double[][] invertUpperTriangular(double[][] r) { int dim = Math.min(r.length, r[0].length); double[][] inv = new double[dim][dim]; for (int i = dim - 1; i >= 0; i--) { inv[i][i] = 1.0 / r[i][i]; for (int j = i + 1; j < dim; j++) { for (int k = i + 1; k < dim; k++) { inv[i][j] -= r[i][k] * inv[k][j]; } inv[i][j] *= inv[i][i]; } } return inv; } }