comparison src/LazyTensors/lazy_tensor_operations.jl @ 1513:d7bc11053951

Fix spelling mistakes
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 21 Mar 2024 15:36:52 +0100
parents 4684c7f1c4cb
children d68d02dd882f
comparison
equal deleted inserted replaced
1499:8ef207e4bc87 1513:d7bc11053951
3 3
4 Struct for lazy application of a LazyTensor. Created using `*`. 4 Struct for lazy application of a LazyTensor. Created using `*`.
5 5
6 Allows the result of a `LazyTensor` applied to a vector to be treated as an `AbstractArray`. 6 Allows the result of a `LazyTensor` applied to a vector to be treated as an `AbstractArray`.
7 With a mapping `m` and a vector `v` the TensorApplication object can be created by `m*v`. 7 With a mapping `m` and a vector `v` the TensorApplication object can be created by `m*v`.
8 The actual result will be calcualted when indexing into `m*v`. 8 The actual result will be calculated when indexing into `m*v`.
9 """ 9 """
10 struct TensorApplication{T,R,D, TM<:LazyTensor{<:Any,R,D}, AA<:AbstractArray{<:Any,D}} <: LazyArray{T,R} 10 struct TensorApplication{T,R,D, TM<:LazyTensor{<:Any,R,D}, AA<:AbstractArray{<:Any,D}} <: LazyArray{T,R}
11 t::TM 11 t::TM
12 o::AA 12 o::AA
13 13
100 100
101 """ 101 """
102 TensorComposition(tm, tmi::IdentityTensor) 102 TensorComposition(tm, tmi::IdentityTensor)
103 TensorComposition(tmi::IdentityTensor, tm) 103 TensorComposition(tmi::IdentityTensor, tm)
104 104
105 Composes a `Tensormapping` `tm` with an `IdentityTensor` `tmi`, by returning `tm` 105 Composes a `LazyTensor` `tm` with an `IdentityTensor` `tmi`, by returning `tm`
106 """ 106 """
107 function TensorComposition(tm::LazyTensor{T,R,D}, tmi::IdentityTensor{T,D}) where {T,R,D} 107 function TensorComposition(tm::LazyTensor{T,R,D}, tmi::IdentityTensor{T,D}) where {T,R,D}
108 @boundscheck check_domain_size(tm, range_size(tmi)) 108 @boundscheck check_domain_size(tm, range_size(tmi))
109 return tm 109 return tm
110 end 110 end
123 Base.:*(tm::LazyTensor{T}, a::T) where T = a*tm 123 Base.:*(tm::LazyTensor{T}, a::T) where T = a*tm
124 124
125 """ 125 """
126 InflatedTensor{T,R,D} <: LazyTensor{T,R,D} 126 InflatedTensor{T,R,D} <: LazyTensor{T,R,D}
127 127
128 An inflated `LazyTensor` with dimensions added before and afer its actual dimensions. 128 An inflated `LazyTensor` with dimensions added before and after its actual dimensions.
129 """ 129 """
130 struct InflatedTensor{T,R,D,D_before,R_middle,D_middle,D_after, TM<:LazyTensor{T,R_middle,D_middle}} <: LazyTensor{T,R,D} 130 struct InflatedTensor{T,R,D,D_before,R_middle,D_middle,D_after, TM<:LazyTensor{T,R_middle,D_middle}} <: LazyTensor{T,R,D}
131 before::IdentityTensor{T,D_before} 131 before::IdentityTensor{T,D_before}
132 tm::TM 132 tm::TM
133 after::IdentityTensor{T,D_after} 133 after::IdentityTensor{T,D_after}
217 217
218 218
219 @doc raw""" 219 @doc raw"""
220 LazyOuterProduct(tms...) 220 LazyOuterProduct(tms...)
221 221
222 Creates a `TensorComposition` for the outerproduct of `tms...`. 222 Creates a `TensorComposition` for the outer product of `tms...`.
223 This is done by separating the outer product into regular products of outer products involving only identity mappings and one non-identity mapping. 223 This is done by separating the outer product into regular products of outer products involving only identity mappings and one non-identity mapping.
224 224
225 First let 225 First let
226 ```math 226 ```math
227 \begin{aligned} 227 \begin{aligned}
276 Inflate `tm` such that it gets the size `sz` in all directions except `dir`. 276 Inflate `tm` such that it gets the size `sz` in all directions except `dir`.
277 Here `sz[dir]` is ignored and replaced with the range and domains size of 277 Here `sz[dir]` is ignored and replaced with the range and domains size of
278 `tm`. 278 `tm`.
279 279
280 An example of when this operation is useful is when extending a one 280 An example of when this operation is useful is when extending a one
281 dimensional difference operator `D` to a 2D grid of a ceratin size. In that 281 dimensional difference operator `D` to a 2D grid of a certain size. In that
282 case we could have 282 case we could have
283 283
284 ```julia 284 ```julia
285 Dx = inflate(D, (10,10), 1) 285 Dx = inflate(D, (10,10), 1)
286 Dy = inflate(D, (10,10), 2) 286 Dy = inflate(D, (10,10), 2)