|
271 | 271 | end |
272 | 272 |
|
273 | 273 | @testset "Type Inference (QuantumObject)" begin |
274 | | - if VERSION >= v"1.10" |
275 | | - for T in [ComplexF32, ComplexF64] |
276 | | - N = 4 |
277 | | - a = rand(T, N) |
278 | | - @inferred QuantumObject{typeof(a),KetQuantumObject} Qobj(a) |
279 | | - for type in [Ket, OperatorKet] |
280 | | - @inferred Qobj(a, type = type) |
281 | | - end |
282 | | - |
283 | | - UnionType = |
284 | | - Union{QuantumObject{Matrix{T},BraQuantumObject,1},QuantumObject{Matrix{T},OperatorQuantumObject,1}} |
285 | | - a = rand(T, 1, N) |
286 | | - @inferred UnionType Qobj(a) |
287 | | - for type in [Bra, OperatorBra] |
288 | | - @inferred Qobj(a, type = type) |
289 | | - end |
290 | | - |
291 | | - a = rand(T, N, N) |
292 | | - @inferred UnionType Qobj(a) |
293 | | - for type in [Operator, SuperOperator] |
294 | | - @inferred Qobj(a, type = type) |
295 | | - end |
| 274 | + for T in [ComplexF32, ComplexF64] |
| 275 | + N = 4 |
| 276 | + a = rand(T, N) |
| 277 | + @inferred QuantumObject{typeof(a),KetQuantumObject} Qobj(a) |
| 278 | + for type in [Ket, OperatorKet] |
| 279 | + @inferred Qobj(a, type = type) |
296 | 280 | end |
297 | 281 |
|
298 | | - @testset "Math Operation" begin |
299 | | - a = destroy(20) |
300 | | - σx = sigmax() |
301 | | - @inferred a + a |
302 | | - @inferred a + a' |
303 | | - @inferred a + 2 |
304 | | - @inferred 2 * a |
305 | | - @inferred a / 2 |
306 | | - @inferred a^2 |
307 | | - @inferred a .+ 2 |
308 | | - @inferred a .* 2 |
309 | | - @inferred a ./ 2 |
310 | | - @inferred a .^ 2 |
311 | | - @inferred a * a |
312 | | - @inferred a * a' |
313 | | - @inferred kron(a, σx) |
314 | | - @inferred kron(a, eye(2)) |
| 282 | + UnionType = |
| 283 | + Union{QuantumObject{Matrix{T},BraQuantumObject,1},QuantumObject{Matrix{T},OperatorQuantumObject,1}} |
| 284 | + a = rand(T, 1, N) |
| 285 | + @inferred UnionType Qobj(a) |
| 286 | + for type in [Bra, OperatorBra] |
| 287 | + @inferred Qobj(a, type = type) |
315 | 288 | end |
| 289 | + |
| 290 | + a = rand(T, N, N) |
| 291 | + @inferred UnionType Qobj(a) |
| 292 | + for type in [Operator, SuperOperator] |
| 293 | + @inferred Qobj(a, type = type) |
| 294 | + end |
| 295 | + end |
| 296 | + |
| 297 | + @testset "Math Operation" begin |
| 298 | + a = destroy(20) |
| 299 | + σx = sigmax() |
| 300 | + @inferred a + a |
| 301 | + @inferred a + a' |
| 302 | + @inferred a + 2 |
| 303 | + @inferred 2 * a |
| 304 | + @inferred a / 2 |
| 305 | + @inferred a^2 |
| 306 | + @inferred a .+ 2 |
| 307 | + @inferred a .* 2 |
| 308 | + @inferred a ./ 2 |
| 309 | + @inferred a .^ 2 |
| 310 | + @inferred a * a |
| 311 | + @inferred a * a' |
| 312 | + @inferred kron(a, σx) |
| 313 | + @inferred kron(a, eye(2)) |
316 | 314 | end |
317 | 315 | end |
318 | 316 |
|
|
0 commit comments