@@ -131,66 +131,6 @@ for cmat in mattypes,
131131 push! (testdata, (cmat{celt}, amat{aelt}, bmat{belt}))
132132end
133133
134- @testset " Alternative multiplication operators" begin
135- for T in (Int, Float32, Float64, BigFloat)
136- a = [T[1 , 2 ], T[- 3 , 7 ]]
137- b = [T[5 , 11 ], T[- 13 , 17 ]]
138- @test map (⋅ , a, b) == map (dot, a, b) == [27 , 158 ]
139- @test map (⊙ , a, b) == map (hadamard, a, b) == [a[1 ]. * b[1 ], a[2 ]. * b[2 ]]
140- @test map (⊗ , a, b) == map (tensor, a, b) == [a[1 ]* transpose (b[1 ]), a[2 ]* transpose (b[2 ])]
141- @test hadamard! (fill (typemax (Int), 2 ), T[1 , 2 ], T[- 3 , 7 ]) == [- 3 , 14 ]
142- @test tensor! (fill (typemax (Int), 2 , 2 ), T[1 , 2 ], T[- 3 , 7 ]) == [- 3 7 ; - 6 14 ]
143- end
144-
145- @test_throws DimensionMismatch [1 ,2 ] ⊙ [3 ]
146- @test_throws DimensionMismatch hadamard! ([0 , 0 , 0 ], [1 ,2 ], [- 3 ,7 ])
147- @test_throws DimensionMismatch hadamard! ([0 , 0 ], [1 ,2 ], [- 3 ])
148- @test_throws DimensionMismatch hadamard! ([0 , 0 ], [1 ], [- 3 ,7 ])
149- @test_throws DimensionMismatch tensor! (Matrix {Int} (undef, 2 , 2 ), [1 ], [- 3 ,7 ])
150- @test_throws DimensionMismatch tensor! (Matrix {Int} (undef, 2 , 2 ), [1 ,2 ], [- 3 ])
151-
152- u, v = [2 + 2im , 3 + 5im ], [1 - 3im , 7 + 3im ]
153- @test u ⋅ v == conj (u[1 ])* v[1 ] + conj (u[2 ])* v[2 ]
154- @test u ⊙ v == [u[1 ]* v[1 ], u[2 ]* v[2 ]]
155- @test u ⊗ v == [u[1 ]* v[1 ] u[1 ]* v[2 ]; u[2 ]* v[1 ] u[2 ]* v[2 ]]
156- @test hadamard (u, v) == u ⊙ v
157- @test tensor (u, v) == u ⊗ v
158- dest = similar (u)
159- @test hadamard! (dest, u, v) == u ⊙ v
160- dest = Matrix {Complex{Int}} (undef, 2 , 2 )
161- @test tensor! (dest, u, v) == u ⊗ v
162-
163- for (A, B, b) in (([1 2 ; 3 4 ], [5 6 ; 7 8 ], [5 ,6 ]),
164- ([1 + 0.8im 2 + 0.7im ; 3 + 0.6im 4 + 0.5im ],
165- [5 + 0.4im 6 + 0.3im ; 7 + 0.2im 8 + 0.1im ],
166- [5 + 0.6im ,6 + 0.3im ]))
167- @test A ⊗ b == cat (A* b[1 ], A* b[2 ]; dims= 3 )
168- @test A ⊗ B == cat (cat (A* B[1 ,1 ], A* B[2 ,1 ]; dims= 3 ),
169- cat (A* B[1 ,2 ], A* B[2 ,2 ]; dims= 3 ); dims= 4 )
170- end
171-
172- A, B = reshape (1 : 27 , 3 , 3 , 3 ), reshape (1 : 4 , 2 , 2 )
173- @test A ⊗ B == [a* b for a in A, b in B]
174-
175- # Adjoint/transpose is a dual vector, not an AbstractMatrix
176- v = [1 ,2 ]
177- @test_throws ErrorException v ⊗ v'
178- @test_throws ErrorException v ⊗ transpose (v)
179- @test_throws ErrorException v' ⊗ v
180- @test_throws ErrorException transpose (v) ⊗ v
181- @test_throws ErrorException v' ⊗ v'
182- @test_throws ErrorException transpose (v) ⊗ transpose (v)
183- @test_throws ErrorException v' ⊗ transpose (v)
184- @test_throws ErrorException transpose (v) ⊗ v'
185- @test_throws ErrorException A ⊗ v'
186- @test_throws ErrorException A ⊗ transpose (v)
187-
188- # Docs comparison to `kron`
189- v, w = [1 ,2 ,3 ], [5 ,7 ]
190- @test kron (v,w) == vec (w ⊗ v)
191- @test w ⊗ v == reshape (kron (v,w), (length (w), length (v)))
192- end
193-
194134@testset " mul!(::$TC , ::$TA , ::$TB , α, β)" for (TC, TA, TB) in testdata
195135 if needsquare (TA)
196136 na1 = na2 = rand (sizecandidates)
0 commit comments