Калькулятор для выражения delta x = -[E - At * (A * At)^-1 * A] * grad F(x) с выводом промежуточных результатов

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import Jama.*;
import static java.lang.System.out;
import static java.lang.Math.max;
class Main {
static Matrix A = new Matrix(new double[][] {
{ 6, 8 }
});
static Matrix gradFx = new Matrix(new double[][] {
{ -1 },
{ -1 }
});
public static void main(String[] args) {
int n = max(A.getRowDimension(), A.getColumnDimension());
Matrix E = new Matrix(n, n);
for (int i = 0; i < n; ++i) {
E.set(i, i, 1.0);
}
Matrix At = A.transpose();
Matrix tmp = A.times(At);
out.print("A * At");
tmp.print(5, 3);
tmp = tmp.inverse();
out.print("(A * At)^-1");
tmp.print(5, 3);
tmp = At.times(tmp);
out.print("At * (A * At)^-1");
tmp.print(5, 3);
tmp = tmp.times(A);
out.print("At * (A * At)^-1 * A");
tmp.print(5, 3);
tmp = E.minus(tmp).uminus();
out.print("-[E - At * (A * At)^-1 * A]");
tmp.print(5, 3);
tmp = tmp.times(gradFx);
out.print("-[E - At * (A * At)^-1 * A] * grad F(x)");
tmp.print(5, 3);
}
}