comparison src/LazyTensors/tensor_mapping.jl @ 995:1ba8a398af9c refactor/lazy_tensors

Rename types
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 18 Mar 2022 21:14:47 +0100
parents 1f41cf9454f2
children
comparison
equal deleted inserted replaced
994:55ab7801c45f 995:1ba8a398af9c
1 export TensorMapping 1 export LazyTensor
2 export apply 2 export apply
3 export apply_transpose 3 export apply_transpose
4 export range_dim, domain_dim 4 export range_dim, domain_dim
5 export range_size, domain_size 5 export range_size, domain_size
6 6
7 """ 7 """
8 TensorMapping{T,R,D} 8 LazyTensor{T,R,D}
9 9
10 Describes a mapping of a `D` dimension tensor to an `R` dimension tensor. 10 Describes a mapping of a `D` dimension tensor to an `R` dimension tensor.
11 The action of the mapping is implemented through the method 11 The action of the mapping is implemented through the method
12 ```julia 12 ```julia
13 apply(t::TensorMapping{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T} 13 apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
14 ``` 14 ```
15 15
16 The size of the range and domain that the operator works with should be returned by 16 The size of the range and domain that the operator works with should be returned by
17 the functions 17 the functions
18 ```julia 18 ```julia
19 range_size(::TensorMapping) 19 range_size(::LazyTensor)
20 domain_size(::TensorMapping) 20 domain_size(::LazyTensor)
21 ``` 21 ```
22 to allow querying for one or the other. 22 to allow querying for one or the other.
23 23
24 Optionally the action of the transpose may be defined through 24 Optionally the action of the transpose may be defined through
25 ```julia 25 ```julia
26 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T} 26 apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
27 ``` 27 ```
28 """ 28 """
29 abstract type TensorMapping{T,R,D} end 29 abstract type LazyTensor{T,R,D} end
30 30
31 """ 31 """
32 apply(t::TensorMapping{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T} 32 apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
33 33
34 Return the result of the mapping for a given index. 34 Return the result of the mapping for a given index.
35 """ 35 """
36 function apply end 36 function apply end
37 37
38 """ 38 """
39 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{<:Any,R}, I::Vararg) where {R,D,T} 39 apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,R}, I::Vararg) where {R,D,T}
40 40
41 Return the result of the transposed mapping for a given index. 41 Return the result of the transposed mapping for a given index.
42 """ 42 """
43 function apply_transpose end 43 function apply_transpose end
44 44
45 """ 45 """
46 range_dim(::TensorMapping) 46 range_dim(::LazyTensor)
47 Return the dimension of the range space of a given mapping 47 Return the dimension of the range space of a given mapping
48 """ 48 """
49 range_dim(::TensorMapping{T,R,D}) where {T,R,D} = R 49 range_dim(::LazyTensor{T,R,D}) where {T,R,D} = R
50 50
51 """ 51 """
52 domain_dim(::TensorMapping) 52 domain_dim(::LazyTensor)
53 Return the dimension of the domain space of a given mapping 53 Return the dimension of the domain space of a given mapping
54 """ 54 """
55 domain_dim(::TensorMapping{T,R,D}) where {T,R,D} = D 55 domain_dim(::LazyTensor{T,R,D}) where {T,R,D} = D
56 56
57 57
58 """ 58 """
59 range_size(M::TensorMapping) 59 range_size(M::LazyTensor)
60 60
61 Return the range size for the mapping. 61 Return the range size for the mapping.
62 """ 62 """
63 function range_size end 63 function range_size end
64 64
65 """ 65 """
66 domain_size(M::TensorMapping) 66 domain_size(M::LazyTensor)
67 67
68 Return the domain size for the mapping. 68 Return the domain size for the mapping.
69 """ 69 """
70 function domain_size end 70 function domain_size end
71 71
72 72
73 """ 73 """
74 eltype(::TensorMapping{T}) 74 eltype(::LazyTensor{T})
75 75
76 The type of elements the TensorMapping acts on. 76 The type of elements the LazyTensor acts on.
77 """ 77 """
78 Base.eltype(::TensorMapping{T}) where T = T 78 Base.eltype(::LazyTensor{T}) where T = T
79 79
80 # TODO: Think about boundschecking! 80 # TODO: Think about boundschecking!