Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 1084:2e606d4c0ab1 feature/scalar_times_tensor
Add support for multiplying a LazyTensor with a scalar
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 14 Apr 2022 18:12:59 +0200 |
parents | 9e76bf19904c |
children | 2278730f9cee 95464a1af340 1e8270c18edb b4ee47f2aafb 87576b0ca0e3 |
comparison
equal
deleted
inserted
replaced
1082:9abb140a4636 | 1084:2e606d4c0ab1 |
---|---|
96 | 96 |
97 function apply_transpose(c::TensorComposition{T,R,K,D}, v::AbstractArray{<:Any,R}, I::Vararg{Any,D}) where {T,R,K,D} | 97 function apply_transpose(c::TensorComposition{T,R,K,D}, v::AbstractArray{<:Any,R}, I::Vararg{Any,D}) where {T,R,K,D} |
98 apply_transpose(c.t2, c.t1'*v, I...) | 98 apply_transpose(c.t2, c.t1'*v, I...) |
99 end | 99 end |
100 | 100 |
101 | |
102 """ | 101 """ |
103 TensorComposition(tm, tmi::IdentityTensor) | 102 TensorComposition(tm, tmi::IdentityTensor) |
104 TensorComposition(tmi::IdentityTensor, tm) | 103 TensorComposition(tmi::IdentityTensor, tm) |
105 | 104 |
106 Composes a `Tensormapping` `tm` with an `IdentityTensor` `tmi`, by returning `tm` | 105 Composes a `Tensormapping` `tm` with an `IdentityTensor` `tmi`, by returning `tm` |
118 function TensorComposition(tm::IdentityTensor{T,D}, tmi::IdentityTensor{T,D}) where {T,D} | 117 function TensorComposition(tm::IdentityTensor{T,D}, tmi::IdentityTensor{T,D}) where {T,D} |
119 @boundscheck check_domain_size(tm, range_size(tmi)) | 118 @boundscheck check_domain_size(tm, range_size(tmi)) |
120 return tmi | 119 return tmi |
121 end | 120 end |
122 | 121 |
122 Base.:*(a::T, tm::LazyTensor{T}) where T = TensorComposition(ScalingTensor{T,range_dim(tm)}(a,range_size(tm)), tm) | |
123 Base.:*(tm::LazyTensor{T}, a::T) where T = a*tm | |
123 | 124 |
124 """ | 125 """ |
125 InflatedTensor{T,R,D} <: LazyTensor{T,R,D} | 126 InflatedTensor{T,R,D} <: LazyTensor{T,R,D} |
126 | 127 |
127 An inflated `LazyTensor` with dimensions added before and afer its actual dimensions. | 128 An inflated `LazyTensor` with dimensions added before and afer its actual dimensions. |