diff 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
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Fri Apr 08 19:36:22 2022 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Thu Apr 14 18:12:59 2022 +0200
@@ -98,7 +98,6 @@
     apply_transpose(c.t2, c.t1'*v, I...)
 end
 
-
 """
     TensorComposition(tm, tmi::IdentityTensor)
     TensorComposition(tmi::IdentityTensor, tm)
@@ -120,6 +119,8 @@
     return tmi
 end
 
+Base.:*(a::T, tm::LazyTensor{T}) where T = TensorComposition(ScalingTensor{T,range_dim(tm)}(a,range_size(tm)), tm)
+Base.:*(tm::LazyTensor{T}, a::T) where T = a*tm
 
 """
     InflatedTensor{T,R,D} <: LazyTensor{T,R,D}