|
80 | 80 |
|
81 | 81 | for f in (:eig_vals, :eigh_vals, :svd_vals) |
82 | 82 | f! = Symbol(f, :!) |
83 | | - @eval MAK.initialize_output(::typeof($f!), a::AbstractMatrix, alg::KroneckerAlgorithm) = nothing |
| 83 | + @eval function MAK.initialize_output( |
| 84 | + ::typeof($f!), a::AbstractMatrix, alg::KroneckerAlgorithm |
| 85 | + ) |
| 86 | + return nothing |
| 87 | + end |
84 | 88 | @eval function MAK.$f!(ab::AbstractKroneckerMatrix, F, alg::KroneckerAlgorithm) |
85 | 89 | a, b = kroneckerfactors(ab) |
86 | 90 | algA, algB = kroneckerfactors(alg) |
87 | 91 | return MAK.$f(a, algA) ⊗ MAK.$f(b, algB) |
88 | 92 | end |
89 | 93 | end |
90 | 94 |
|
91 | | -for f in (:left_orth, :right_orth) |
92 | | - f! = Symbol(f, :!) |
93 | | - @eval MAK.initialize_output(::typeof($f!), a::AbstractKroneckerMatrix) = nothing |
94 | | - @eval function MAK.$f!(ab::AbstractKroneckerMatrix, F; kwargs1 = (;), kwargs2 = (;), kwargs...) |
95 | | - a, b = kroneckerfactors(ab) |
96 | | - Fa = MAK.$f(a; kwargs..., kwargs1...) |
97 | | - Fb = MAK.$f(b; kwargs..., kwargs2...) |
98 | | - return Fa .⊗ Fb |
| 95 | +# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104 |
| 96 | +# is merged. |
| 97 | +for kind in ("polar", "qr", "svd") |
| 98 | + @eval begin |
| 99 | + function MAK.initialize_output( |
| 100 | + ::typeof(left_orth!), a::AbstractKroneckerMatrix, |
| 101 | + alg::MAK.LeftOrthAlgorithm{Symbol($kind)}, |
| 102 | + ) |
| 103 | + return nothing |
| 104 | + end |
| 105 | + function MAK.left_orth!( |
| 106 | + ab::AbstractKroneckerMatrix, F, alg::MAK.LeftOrthAlgorithm{Symbol($kind)}; |
| 107 | + kwargs1 = (;), kwargs2 = (;), kwargs..., |
| 108 | + ) |
| 109 | + a, b = kroneckerfactors(ab) |
| 110 | + Fa = MAK.left_orth!(a; kwargs..., kwargs1...) |
| 111 | + Fb = MAK.left_orth!(b; kwargs..., kwargs2...) |
| 112 | + return Fa .⊗ Fb |
| 113 | + end |
99 | 114 | end |
100 | 115 | end |
101 | 116 |
|
102 | | -for f in [:left_null, :right_null] |
103 | | - f! = Symbol(f, :!) |
104 | | - @eval MAK.initialize_output(::typeof($f!), a::AbstractKroneckerMatrix) = |
105 | | - nothing |
106 | | - @eval function MAK.$f!(ab::AbstractKroneckerMatrix, F; kwargs1 = (;), kwargs2 = (;), kwargs...) |
107 | | - a, b = kroneckerfactors(ab) |
108 | | - Na = MAK.$f(a; kwargs..., kwargs1...) |
109 | | - Nb = MAK.$f(b; kwargs..., kwargs2...) |
110 | | - return Na ⊗ Nb |
| 117 | +# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104 |
| 118 | +# is merged. |
| 119 | +for kind in ("lq", "polar", "svd") |
| 120 | + @eval begin |
| 121 | + function MAK.initialize_output( |
| 122 | + ::typeof(right_orth!), a::AbstractKroneckerMatrix, |
| 123 | + alg::MAK.RightOrthAlgorithm{Symbol($kind)}, |
| 124 | + ) |
| 125 | + return nothing |
| 126 | + end |
| 127 | + function MAK.right_orth!( |
| 128 | + ab::AbstractKroneckerMatrix, F, alg::MAK.RightOrthAlgorithm{Symbol($kind)}; |
| 129 | + kwargs1 = (;), kwargs2 = (;), kwargs..., |
| 130 | + ) |
| 131 | + a, b = kroneckerfactors(ab) |
| 132 | + Fa = MAK.right_orth!(a; kwargs..., kwargs1...) |
| 133 | + Fb = MAK.right_orth!(b; kwargs..., kwargs2...) |
| 134 | + return Fa .⊗ Fb |
| 135 | + end |
| 136 | + end |
| 137 | +end |
| 138 | + |
| 139 | +# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104 |
| 140 | +# is merged. |
| 141 | +for Alg in ( |
| 142 | + :(MAK.LeftNullViaQR), |
| 143 | + :(MAK.LeftNullViaSVD{<:MAK.TruncatedAlgorithm}), |
| 144 | + :(MAK.LeftNullViaSVD{<:MAK.TruncatedAlgorithm{<:MAK.GPU_Randomized}}), |
| 145 | + ) |
| 146 | + @eval begin |
| 147 | + function MAK.initialize_output( |
| 148 | + ::typeof(left_null!), a::AbstractKroneckerMatrix, alg::$Alg |
| 149 | + ) |
| 150 | + return nothing |
| 151 | + end |
| 152 | + function MAK.left_null!( |
| 153 | + ab::AbstractKroneckerMatrix, F, alg::$Alg; |
| 154 | + kwargs1 = (;), kwargs2 = (;), kwargs..., |
| 155 | + ) |
| 156 | + a, b = kroneckerfactors(ab) |
| 157 | + Na = MAK.left_null!(a; kwargs..., kwargs1...) |
| 158 | + Nb = MAK.left_null!(b; kwargs..., kwargs2...) |
| 159 | + return Na ⊗ Nb |
| 160 | + end |
| 161 | + end |
| 162 | +end |
| 163 | + |
| 164 | +# TODO: Delete this loop once https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/104 |
| 165 | +# is merged. |
| 166 | +for Alg in ( |
| 167 | + :(MAK.RightNullViaLQ), |
| 168 | + :(MAK.RightNullViaSVD{<:MAK.TruncatedAlgorithm}), |
| 169 | + :(MAK.RightNullViaSVD{<:MAK.TruncatedAlgorithm{<:MAK.GPU_Randomized}}), |
| 170 | + ) |
| 171 | + @eval begin |
| 172 | + function MAK.initialize_output( |
| 173 | + ::typeof(right_null!), a::AbstractKroneckerMatrix, alg::$Alg |
| 174 | + ) |
| 175 | + return nothing |
| 176 | + end |
| 177 | + function MAK.right_null!( |
| 178 | + ab::AbstractKroneckerMatrix, F, alg::$Alg; |
| 179 | + kwargs1 = (;), kwargs2 = (;), kwargs..., |
| 180 | + ) |
| 181 | + a, b = kroneckerfactors(ab) |
| 182 | + Na = MAK.right_null!(a; kwargs..., kwargs1...) |
| 183 | + Nb = MAK.right_null!(b; kwargs..., kwargs2...) |
| 184 | + return Na ⊗ Nb |
| 185 | + end |
111 | 186 | end |
112 | 187 | end |
113 | 188 |
|
|
0 commit comments