Mercurial > repos > public > sbplib_julia
comparison test/LazyTensors/lazy_tensor_operations_test.jl @ 942:7829c09f8137 feature/tensormapping_application_promotion
Add promotion calculation of element type for LazyTensorMappingApplication
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 10 Mar 2022 11:13:34 +0100 |
parents | de2df1214394 |
children | fb060e98ac0a |
comparison
equal
deleted
inserted
replaced
921:de1625deb27e | 942:7829c09f8137 |
---|---|
72 | 72 |
73 m = ScalingOperator{Int,2}(2,(2,2)) | 73 m = ScalingOperator{Int,2}(2,(2,2)) |
74 v = [[1 2];[3 4]] | 74 v = [[1 2];[3 4]] |
75 @test m*v == [[2 4];[6 8]] | 75 @test m*v == [[2 4];[6 8]] |
76 @test (m*v)[2,1] == 6 | 76 @test (m*v)[2,1] == 6 |
77 | |
78 @testset "Promotion" begin | |
79 m = ScalingOperator{Int,1}(2,(3,)) | |
80 v = [1.,2.,3.] | |
81 @test m*v isa AbstractVector{Float64} | |
82 @test m*v == [2.,4.,6.] | |
83 | |
84 m = ScalingOperator{Int,2}(2,(2,2)) | |
85 v = [[1. 2.];[3. 4.]] | |
86 @test m*v == [[2. 4.];[6. 8.]] | |
87 @test (m*v)[2,1] == 6. | |
88 | |
89 m = ScalingOperator{ComplexF64,1}(2. +2. *im,(3,)) | |
90 v = [1.,2.,3.] | |
91 @test m*v isa AbstractVector{ComplexF64} | |
92 @test m*v == [2. + 2. *im, 4. + 4. *im, 6. + 6. *im] | |
93 | |
94 m = ScalingOperator{ComplexF64,1}(1,(3,)) | |
95 v = [2. + 2. *im, 4. + 4. *im, 6. + 6. *im] | |
96 @test m*v isa AbstractVector{ComplexF64} | |
97 @test m*v == [2. + 2. *im, 4. + 4. *im, 6. + 6. *im] | |
98 end | |
77 end | 99 end |
78 | 100 |
79 @testset "TensorMapping binary operations" begin | 101 @testset "TensorMapping binary operations" begin |
80 struct ScalarMapping{T,R,D} <: TensorMapping{T,R,D} | 102 struct ScalarMapping{T,R,D} <: TensorMapping{T,R,D} |
81 λ::T | 103 λ::T |