@@ -7,31 +7,35 @@ using MatrixAlgebraKit:
7
7
right_polar!,
8
8
svd_compact!
9
9
10
- function MatrixAlgebraKit. check_input (
11
- :: typeof (left_polar!), A:: AbstractBlockSparseMatrix , WP
12
- )
13
- W, P = WP
10
+ function MatrixAlgebraKit. check_input (:: typeof (left_polar!), A:: AbstractBlockSparseMatrix )
14
11
@views for I in eachblockstoredindex (A)
15
12
m, n = size (A[I])
16
13
m >= n ||
17
14
throw (ArgumentError (" each input matrix block needs at least as many rows as columns" ))
18
- # check_input(left_polar!, A[I], (W[I1], P[I2]))
15
+ end
16
+ return nothing
17
+ end
18
+ function MatrixAlgebraKit. check_input (:: typeof (right_polar!), A:: AbstractBlockSparseMatrix )
19
+ @views for I in eachblockstoredindex (A)
20
+ m, n = size (A[I])
21
+ m <= n ||
22
+ throw (ArgumentError (" each input matrix block needs at least as many columns as rows" ))
19
23
end
20
24
return nothing
21
25
end
22
26
23
- function MatrixAlgebraKit. left_polar! (A:: AbstractBlockSparseMatrix , WP, alg:: PolarViaSVD )
24
- check_input (left_polar!, A, WP)
25
- U, S, Vᴴ = svd_compact! (A, alg. svdalg)
27
+ function MatrixAlgebraKit. left_polar! (A:: AbstractBlockSparseMatrix , alg:: PolarViaSVD )
28
+ check_input (left_polar!, A)
26
29
# TODO : Use more in-place operations here, avoid `copy`.
30
+ U, S, Vᴴ = svd_compact! (A, alg. svdalg)
27
31
W = U * Vᴴ
28
32
P = copy (Vᴴ' ) * S * Vᴴ
29
33
return (W, P)
30
34
end
31
- function MatrixAlgebraKit. right_polar! (A:: AbstractBlockSparseMatrix , PWᴴ, alg:: PolarViaSVD )
32
- check_input (right_polar!, A, PWᴴ)
33
- U, S, Vᴴ = svd_compact! (A, alg. svdalg)
35
+ function MatrixAlgebraKit. right_polar! (A:: AbstractBlockSparseMatrix , alg:: PolarViaSVD )
36
+ check_input (right_polar!, A)
34
37
# TODO : Use more in-place operations here, avoid `copy`.
38
+ U, S, Vᴴ = svd_compact! (A, alg. svdalg)
35
39
Wᴴ = U * Vᴴ
36
40
P = U * S * copy (U' )
37
41
return (P, Wᴴ)
0 commit comments