|
2 | 2 | @testset "Matrix-vector" begin
|
3 | 3 | m = @SMatrix [1 2; 3 4]
|
4 | 4 | v = @SVector [1, 2]
|
| 5 | + v_bad = @SVector [1, 2, 3] |
5 | 6 | @test m*v === @SVector [5, 11]
|
| 7 | + @test_throws DimensionMismatch m*v_bad |
6 | 8 | # More complicated eltype inference
|
7 | 9 | v2 = @SVector [CartesianIndex((1,3)), CartesianIndex((3,1))]
|
8 | 10 | x = @inferred(m*v2)
|
|
17 | 19 |
|
18 | 20 | v3 = [1, 2]
|
19 | 21 | @test m*v3 === @SVector [5, 11]
|
| 22 | + v3_bad = [1, 2, 3] |
| 23 | + @test_throws DimensionMismatch m*v3_bad |
20 | 24 |
|
21 | 25 | m2 = @MMatrix [1 2; 3 4]
|
22 | 26 | v4 = @MVector [1, 2]
|
|
141 | 145 | m = MMatrix{16,16}(m_array)
|
142 | 146 | n = MMatrix{16,16}(n_array)
|
143 | 147 | @test m*n::MMatrix ≈ a_array
|
| 148 | + |
| 149 | + # Complex numbers |
| 150 | + m_array = randn(4, 4) |
| 151 | + n_array = im*randn(4, 4) |
| 152 | + a_array = m_array*n_array |
| 153 | + |
| 154 | + m = MMatrix{4,4}(m_array) |
| 155 | + n = MMatrix{4,4}(n_array) |
| 156 | + @test m*n::MMatrix ≈ a_array |
| 157 | + |
| 158 | + m_array = randn(10, 10) |
| 159 | + n_array = im*randn(10, 10) |
| 160 | + a_array = m_array*n_array |
| 161 | + |
| 162 | + m = MMatrix{10,10}(m_array) |
| 163 | + n = MMatrix{10,10}(n_array) |
| 164 | + @test m*n::MMatrix ≈ a_array |
| 165 | + |
| 166 | + m_array = randn(16, 16) |
| 167 | + n_array = im*randn(16, 16) |
| 168 | + a_array = m_array*n_array |
| 169 | + |
| 170 | + m = MMatrix{16,16}(m_array) |
| 171 | + n = MMatrix{16,16}(n_array) |
| 172 | + @test m*n::MMatrix ≈ a_array |
| 173 | + |
| 174 | + # Bad dimensions |
| 175 | + m_array = randn(16, 16) |
| 176 | + n_array = randn(17, 17) |
| 177 | + m = MMatrix{16,16}(m_array) |
| 178 | + n = MMatrix{17,17}(n_array) |
| 179 | + @test_throws DimensionMismatch m*n |
| 180 | + m_array = randn(10, 10) |
| 181 | + n_array = randn(11, 11) |
| 182 | + m = MMatrix{10,10}(m_array) |
| 183 | + n = MMatrix{11,11}(n_array) |
| 184 | + @test_throws DimensionMismatch m*n |
| 185 | + m_array = randn(4, 4) |
| 186 | + n_array = randn(3, 3) |
| 187 | + m = MMatrix{4,4}(m_array) |
| 188 | + n = MMatrix{3,3}(n_array) |
| 189 | + @test_throws DimensionMismatch m*n |
144 | 190 | end
|
145 | 191 |
|
146 | 192 | @testset "A_mul_B!" begin
|
|
156 | 202 | A_mul_B!(outvec2, m, v2)
|
157 | 203 | @test outvec2 == [10,22]
|
158 | 204 |
|
| 205 | + # Bad dimensions |
| 206 | + outvec_bad = MVector{3,Int}() |
| 207 | + @test_throws DimensionMismatch A_mul_B!(outvec_bad, m, v) |
| 208 | + |
159 | 209 | a = MMatrix{2,2,Int,4}()
|
160 | 210 | A_mul_B!(a, m, n)
|
161 | 211 | @test a::MMatrix{2,2,Int,4} == @MMatrix [10 13; 22 29]
|
162 | 212 |
|
| 213 | + a = MMatrix{2,2,Int,4}() |
163 | 214 | Ac_mul_B!(a, m, n)
|
164 | 215 | @test a::MMatrix{2,2,Int,4} == @MMatrix [14 18; 20 26]
|
165 | 216 | A_mul_Bc!(a, m, n)
|
|
0 commit comments