Code:
import java.math.BigDecimal;
import java.math.RoundingMode;
public class understandme
{
final static int n = 12;
final static int scale = 10;
public static void main(String arg[])
{
BigDecimal A[][] = new BigDecimal[n][n];
BigDecimal L[][] = new BigDecimal[n][n];
BigDecimal R[][] = new BigDecimal[n][n];
BigDecimal y[] = new BigDecimal[n];
BigDecimal x[] = new BigDecimal[n];
BigDecimal b[] = new BigDecimal[n];
BigDecimal tmp;
int i, j, k, l, m;
int A_int[][] = {
{0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0},
{1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0},
{1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0},
{0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0},
{0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
};
int b_int[] = {344, 420, 581, 865, 693, 323, 667, 463, 524, 528, 455, 10};
for(i = 0; i < n; i++)
{
for(j = 0; j < n; j++)
A[i][j] = new BigDecimal(A_int[i][j]);
b[i] = new BigDecimal(b_int[i]);
x[i] = new BigDecimal(0);
y[i] = new BigDecimal(0);
}
for(j = 0; j < n-1; j++)
{
for(m = j; m < n; m++)
if (A[m][j].doubleValue() != 0.0f) break;
if (m == n) return;
for(l = 0; l < n; l++)
{
tmp = A[m][l]; A[m][l] = A[j][l]; A[j][l] = tmp;
}
tmp = b[m]; b[m] = b[j]; b[j] = tmp;
for(k = j+1; k < n; k++)
{
A[k][j] = A[k][j].divide(A[j][j], scale, RoundingMode.HALF_UP);
for(i = j+1; i < n; i++)
A[k][i] = A[k][i].subtract(A[k][j].multiply(A[j][i]));
}
}
for(i = 0; i < n; i++)
{
for(j = 0; j < n; j++)
{
R[i][j] = L[i][j] = new BigDecimal(0);
if (i == j) L[i][j] = new BigDecimal(1);
if (i <= j) R[i][j] = A[i][j];
else L[i][j] = A[i][j];
}
}
for(k = 0; k < n; k++)
{
for(j = 0; j < k; j++)
y[k] = y[k].add(L[k][j].multiply(y[j]));
y[k] = b[k].subtract(y[k]).divide(L[k][k], scale, RoundingMode.HALF_UP);
}
for(k = n-1; k >= 0; k--)
{
for(j = k+1; j < n; j++)
x[k] = x[k].add(R[k][j].multiply(x[j]));
x[k] = y[k].subtract(x[k]).divide(R[k][k], scale, RoundingMode.HALF_UP);
}
for(i = 0; i < n; i++)
System.out.print((char) Math.round(x[i].doubleValue()));
}
}