user
A
{\displaystyle {\displaystyle A}}
 is any m by n matrix, square or rectangular. Its rank is r. We will diagonalize this A, but not by 

X

−
1
A
X
{\displaystyle {\displaystyle X^{-1}AX}}
.
The eigenvectors in 

X
{\displaystyle {\displaystyle X}}
 have three big problems: They are usually not orthogonal, there
are not always enough eigenvectors, and 

A
x
{\displaystyle {\displaystyle Ax}}
 = 

λ
x
{\displaystyle {\displaystyle \lambda x}}
 requires 

A
{\displaystyle {\displaystyle A}}
 to be a square matrix. The
singular vectors of 

A
{\displaystyle {\displaystyle A}}
 solve all those problems in a perfect way.

The Singular Value Decomposition (SVD)

According to the web page above, for any rectangular matrix 

A
{\displaystyle {\displaystyle A}}
, we can decomposite it as 

A
=
U
Σ

V

T
{\displaystyle {\displaystyle A=U\Sigma V^{T}}}

**Task Description**

Firstly, input two numbers "m" and "n".

Then, input a square/rectangular matrix 

A

m
×
n
{\displaystyle {\displaystyle A^{m\times n}}}
.

Finally, output 

U
,
 
Σ
,
 
V
{\displaystyle {\displaystyle U,~\Sigma ,\ V}}
 with respect to 

A
{\displaystyle {\displaystyle A}}
.

**Example**

**Sample Input**

```
2 2
3 0
4 5

```

From the input above we can know that 

A
{\displaystyle {\displaystyle A}}
 is a 2 by 2 matrix.

**Sample Output**

```
   
0.31622776601683794 -0.9486832980505138
0.9486832980505138 0.31622776601683794

6.708203932499369 0
0 2.23606797749979

0.7071067811865475 -0.7071067811865475
0.7071067811865475 0.7071067811865475

```

The output may vary depending your choice of the data types.

**Remark**

1. It’s encouraged to implement the algorithm by yourself while using libraries is still acceptible.

2. The algorithm should be applicable for general case(

m
×
n
{\displaystyle {\displaystyle m\times n}}
).
assistant
```
# 20230108 Raku programming solution

use Math::Libgsl::Matrix;
use Math::Libgsl::LinearAlgebra;

my @M = <3 0>, <4 5>;
my Math::Libgsl::Matrix \M .= new: @M.elems, @M.first.elems;
(^M.size1)>>.&{ M.set-row: $_, @M[$_;*] }

my (\V,\S) = SV-decomp M;

say "U factor: "        and say (^M.size1)>>.&{ M.get-row($_)>>.fmt: '%.10g' }
say "singular values: " and say (^S.size )>>.&{     S.get($_)>>.fmt: '%.10g' }
say "Vt factor: "       and say (^V.size1)>>.&{ V.get-row($_)>>.fmt: '%.10g' }

```

Output:

```
U factor: 
([-0.316227766 -0.9486832981] [-0.9486832981 0.316227766])
singular values: 
((6.708203932) (2.236067977))
Vt factor: 
([-0.7071067812 -0.7071067812] [-0.7071067812 0.7071067812])
```