Tue May 20 22:34:07 2025 svd_test(): python version: 3.10.12 numpy version: 1.26.4 svd() carries out the singular value decomposition. A real MxN matrix A can be factored as: A = U * S * V where U = MxM orthogonal, S = MxN zero except for diagonal, V = NxN orthogonal. The diagonal of S contains only nonnegative numbers and these are arranged in descending order. Matrix row order M = 3 Matrix column order N = 3 We choose a "random" matrix A, with integral values between 0 and 10. The matrix A: Col: 0 1 2 Row 0 : 6 9 8 1 : 6 2 5 2 : 6 7 2 The orthogonal factor U: Col: 0 1 2 Row 0 : -0.755859 -0.0142148 0.65458 1 : -0.414667 0.784087 -0.461799 2 : -0.506684 -0.620488 -0.598554 The diagonal factor S: Col: 0 1 2 Row 0 : 17.5971 0 0 1 : 0 3.97678 0 2 : 0 0 3.0866 The orthogonal factor V: Col: 0 1 2 Row 0 : -0.57187 0.225385 -0.788775 1 : -0.635266 -0.730031 0.251976 2 : -0.519039 0.64518 0.560662 svd_product_test( ): Compare A and U*S*V'. The product U * S * V Col: 0 1 2 Row 0 : 6 9 8 1 : 6 2 5 2 : 6 7 2 Frobenius Norm of A, A_NORM = 18.303005 ABSOLUTE ERROR for A = U*S*V': Frobenius norm of difference A-U*S*V' = 0.000000 RELATIVE ERROR for A = U*S*V': Ratio of DIF_NORM / A_NORM = 0.000000 rank_one_test(): Compare A to the sum of R rank one matrices. R Absolute Relative Error Error 0 18.303005 1.000000 1 5.034076 0.275041 2 3.086601 0.168639 3 0.000000 0.000000 rank_one_print_test(): Print the sums of R rank one matrices. Rank R = 0 Col: 0 1 2 Row 0 : 0 0 0 1 : 0 0 0 2 : 0 0 0 Rank R = 1 Col: 0 1 2 Row 0 : 7.6064 8.44963 6.90369 1 : 4.17291 4.63551 3.7874 2 : 5.09889 5.66414 4.62783 Rank R = 2 Col: 0 1 2 Row 0 : 7.59366 8.4909 6.86722 1 : 4.87569 2.35916 5.79916 2 : 4.54274 7.46552 3.03582 Rank R = 3 Col: 0 1 2 Row 0 : 6 9 8 1 : 6 2 5 2 : 6 7 2 Original matrix A: Col: 0 1 2 Row 0 : 6 9 8 1 : 6 2 5 2 : 6 7 2 The pseudoinverse of A: Col: 0 1 2 Row 0 : -0.143519 0.175926 0.134259 1 : 0.0833333 -0.166667 0.0833333 2 : 0.138889 0.0555556 -0.194444 pseudo_product_test(): The following relations MUST hold: A * A+ * A = A A+ * A * A+ = A+ ( A * A+ ) is MxM symmetric ( A+ * A ) is NxN symmetric Here are the Frobenius norms of the errors in these relationships: A * A+ * A = A 0.000000 A+ * A * A+ = A+ 0.000000 ( A * A+ ) is MxM symmetric 0.000000 ( A+ * A ) is NxN symmetric 0.000000 In some cases, the matrix A * A+ may be interesting (if M <= N, then it MIGHT look like the identity.) A * A+: Col: 0 1 2 Row 0 : 1 3.33067e-16 0 1 :-2.08167e-15 1 1.80411e-15 2 : 9.4369e-16 -1.66533e-16 1 In some cases, the matrix A+ * A may be interesting (if N <= M, then it MIGHT look like the identity.) A+ * A Col: 0 1 2 Row 0 : 1 -1.02696e-15 -9.4369e-16 1 :-1.02696e-15 1 1.66533e-15 2 : 1.27676e-15 -2.77556e-17 1 pseudo_linear_solve_test(): Given: b = A * x1 so that b is in the range of A, solve A * x = b using the pseudoinverse: x2 = A+ * b. Norm of x1 = 12.884099 Norm of x2 = 12.884099 Norm of residual = 0.000000 Given: b = A * x1 so that b is in the range of A, solve A * x = b using the pseudoinverse: x2 = A+ * b. Norm of x1 = 5.744563 Norm of x2 = 5.744563 Norm of residual = 0.000000 svd_test(): Normal end of execution. Tue May 20 22:34:08 2025