|
| 1 | +using Test |
| 2 | +using Reactant |
| 3 | + |
| 4 | +@testset "conj" begin |
| 5 | + @testset "$(typeof(x))" for x in (1.0, 1.0 + 2.0im) |
| 6 | + x_concrete = Reactant.to_rarray(x) |
| 7 | + f = @compile conj(x_concrete) |
| 8 | + @test only(f(x_concrete)) == conj(x) |
| 9 | + end |
| 10 | + |
| 11 | + @testset "$(typeof(x))" for x in ( |
| 12 | + fill(1.0 + 2.0im), |
| 13 | + fill(1.0), |
| 14 | + [1.0 + 2.0im; 3.0 + 4.0im], |
| 15 | + [1.0; 3.0], |
| 16 | + [1.0 + 2.0im 3.0 + 4.0im], |
| 17 | + [1.0 2.0], |
| 18 | + [1.0+2.0im 3.0+4.0im; 5.0+6.0im 7.0+8.0im], |
| 19 | + [1.0 3.0; 5.0 7.0], |
| 20 | + ) |
| 21 | + x_concrete = Reactant.to_rarray(x) |
| 22 | + f = @compile conj(x_concrete) |
| 23 | + @test f(x_concrete) == conj(x) |
| 24 | + end |
| 25 | +end |
| 26 | + |
| 27 | +@testset "conj!" begin |
| 28 | + @testset "$(typeof(x))" for x in ( |
| 29 | + fill(1.0 + 2.0im), |
| 30 | + fill(1.0), |
| 31 | + [1.0 + 2.0im; 3.0 + 4.0im], |
| 32 | + [1.0; 3.0], |
| 33 | + [1.0 + 2.0im 3.0 + 4.0im], |
| 34 | + [1.0 2.0], |
| 35 | + [1.0+2.0im 3.0+4.0im; 5.0+6.0im 7.0+8.0im], |
| 36 | + [1.0 3.0; 5.0 7.0], |
| 37 | + ) |
| 38 | + x_concrete = Reactant.to_rarray(x) |
| 39 | + f = @compile conj!(x_concrete) |
| 40 | + @test f(x_concrete) == conj(x) |
| 41 | + @test x_concrete == conj(x) |
| 42 | + end |
| 43 | +end |
| 44 | + |
| 45 | +@testset "real" begin |
| 46 | + @testset "$(typeof(x))" for x in (1.0, 1.0 + 2.0im) |
| 47 | + x_concrete = Reactant.to_rarray(x) |
| 48 | + f = @compile real(x_concrete) |
| 49 | + @test only(f(x_concrete)) == real(x) |
| 50 | + end |
| 51 | + |
| 52 | + @testset "$(typeof(x))" for x in ( |
| 53 | + fill(1.0 + 2.0im), |
| 54 | + fill(1.0), |
| 55 | + [1.0 + 2.0im; 3.0 + 4.0im], |
| 56 | + [1.0; 3.0], |
| 57 | + [1.0 + 2.0im 3.0 + 4.0im], |
| 58 | + [1.0 2.0], |
| 59 | + [1.0+2.0im 3.0+4.0im; 5.0+6.0im 7.0+8.0im], |
| 60 | + [1.0 3.0; 5.0 7.0], |
| 61 | + ) |
| 62 | + x_concrete = Reactant.to_rarray(x) |
| 63 | + f = @compile real(x_concrete) |
| 64 | + @test f(x_concrete) == real(x) |
| 65 | + end |
| 66 | +end |
| 67 | + |
| 68 | +@testset "imag" begin |
| 69 | + @testset "$(typeof(x))" for x in (1.0, 1.0 + 2.0im) |
| 70 | + x_concrete = Reactant.to_rarray(x) |
| 71 | + f = @compile imag(x_concrete) |
| 72 | + @test only(f(x_concrete)) == imag(x) |
| 73 | + end |
| 74 | + |
| 75 | + @testset "$(typeof(x))" for x in ( |
| 76 | + fill(1.0 + 2.0im), |
| 77 | + fill(1.0), |
| 78 | + [1.0 + 2.0im; 3.0 + 4.0im], |
| 79 | + [1.0; 3.0], |
| 80 | + [1.0 + 2.0im 3.0 + 4.0im], |
| 81 | + [1.0 2.0], |
| 82 | + [1.0+2.0im 3.0+4.0im; 5.0+6.0im 7.0+8.0im], |
| 83 | + [1.0 3.0; 5.0 7.0], |
| 84 | + ) |
| 85 | + x_concrete = Reactant.to_rarray(x) |
| 86 | + f = @compile imag(x_concrete) |
| 87 | + @test f(x_concrete) == imag(x) |
| 88 | + end |
| 89 | +end |
0 commit comments