1

我有以下矩阵:

 0.003,0.013,0.022,0.013,0.003
 0.013,0.060,0.098,0.060,0.013
 0.022,0.098,0.162,0.098,0.022
 0.013,0.060,0.098,0.060,0.013
 0.003,0.013,0.022,0.013,0.003

我正在尝试使用 la4j 来计算其奇异值分解,使用以下代码:

  SingularValueDecompositor SVD = new SingularValueDecompositor(A);
  Matrix[] factorization = SVD.decompose();

  Matrix U = factorization[0];
  Matrix D = factorization[1];
  Matrix V = factorization[2];

但是,U、D、V 的结果依次为:

0.102,-0.826, 0.307,-0.456,-0.071
0.456,-0.175,-0.859,-0.155,-0.017
0.751, 0.423, 0.374,-0.337,-0.059
0.456,-0.320, 0.166, 0.740, 0.339
0.102,-0.076, 0.029, 0.327,-0.936

-----------
.2873094460,.0000000000,.0000000000,.0000000000,.0000000000
.0000000000,.0000000000,.0000000000,.0000000000,.0000000000
.0000000000,.0000000000,.0000000000,.0000000000,.0000000000
.0000000000,.0000000000,.0000000000,.0000000000,.0000000000
.0000000000,.0000000000,.0000000000,.0000000000,.0000000000

-----------
0.102,-0.051, 0.975,-0.148,-0.122
0.456, 0.870, 0.030, 0.186, 0.027
0.751,-0.481,-0.015, 0.374, 0.253
0.456,-0.079,-0.221,-0.627,-0.586
0.102, 0.061,-0.009,-0.640, 0.759

这三个矩阵相乘

0.003,-0.001,0.028,-0.004,-0.004
0.013,-0.007,0.128,-0.019,-0.016
0.022,-0.011,0.210,-0.032,-0.026
0.013,-0.007,0.128,-0.019,-0.016
0.003,-0.001,0.028,-0.004,-0.004

这不是 A。我认为部分问题可能是实际对角线奇异值小于 0.001(第一个除外),因此它们不会出现。(小数是 10 位的原因是因为我将十进制格式设置为)。我的问题是,我如何解决这个问题并让所有奇异值显示出来?

4

1 回答 1

1

奇异值分解试图将矩阵分解AA = U * D * V'V'转置V

// Instead of 
A = U.multiply(D.multiply(V));

// Try
A = U.multiply(D.multiply(V.transpose()));

// You should get back:
0.0030    0.0134    0.0220    0.0134    0.0030
0.0134    0.0597    0.0984    0.0597    0.0134
0.0220    0.0984    0.1620    0.0984    0.0220
0.0134    0.0597    0.0984    0.0597    0.0134
0.0030    0.0134    0.0220    0.0134    0.0030
于 2018-05-22T20:27:53.063 回答