comparison src/LazyTensors/tensor_mapping.jl @ 988:83046af6143a

Merge feature/tensormapping_application_promotion
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 16 Mar 2022 18:39:00 +0100
parents 1f41cf9454f2
children 1ba8a398af9c
comparison
equal deleted inserted replaced
985:1b4f31ae114f 988:83046af6143a
1 export TensorMapping
2 export apply
3 export apply_transpose
4 export range_dim, domain_dim
5 export range_size, domain_size
6
1 """ 7 """
2 TensorMapping{T,R,D} 8 TensorMapping{T,R,D}
3 9
4 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.
5 The action of the mapping is implemented through the method 11 The action of the mapping is implemented through the method
6 ```julia 12 ```julia
7 apply(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T} 13 apply(t::TensorMapping{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
8 ``` 14 ```
9 15
10 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
11 the functions 17 the functions
12 ```julia 18 ```julia
19 ```julia 25 ```julia
20 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T} 26 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
21 ``` 27 ```
22 """ 28 """
23 abstract type TensorMapping{T,R,D} end 29 abstract type TensorMapping{T,R,D} end
24 export TensorMapping
25 30
26 """ 31 """
27 apply(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T} 32 apply(t::TensorMapping{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
28 33
29 Return the result of the mapping for a given index. 34 Return the result of the mapping for a given index.
30 """ 35 """
31 function apply end 36 function apply end
32 export apply
33 37
34 """ 38 """
35 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,R}, I::Vararg) where {R,D,T} 39 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{<:Any,R}, I::Vararg) where {R,D,T}
36 40
37 Return the result of the transposed mapping for a given index. 41 Return the result of the transposed mapping for a given index.
38 """ 42 """
39 function apply_transpose end 43 function apply_transpose end
40 export apply_transpose
41 44
42 """ 45 """
43 range_dim(::TensorMapping) 46 range_dim(::TensorMapping)
44 Return the dimension of the range space of a given mapping 47 Return the dimension of the range space of a given mapping
45 """ 48 """
49 domain_dim(::TensorMapping) 52 domain_dim(::TensorMapping)
50 Return the dimension of the domain space of a given mapping 53 Return the dimension of the domain space of a given mapping
51 """ 54 """
52 domain_dim(::TensorMapping{T,R,D}) where {T,R,D} = D 55 domain_dim(::TensorMapping{T,R,D}) where {T,R,D} = D
53 56
54 export range_dim, domain_dim
55 57
56 """ 58 """
57 range_size(M::TensorMapping) 59 range_size(M::TensorMapping)
58 60
59 Return the range size for the mapping. 61 Return the range size for the mapping.
65 67
66 Return the domain size for the mapping. 68 Return the domain size for the mapping.
67 """ 69 """
68 function domain_size end 70 function domain_size end
69 71
70 export range_size, domain_size
71 72
72 """ 73 """
73 eltype(::TensorMapping{T}) 74 eltype(::TensorMapping{T})
74 75
75 The type of elements the TensorMapping acts on. 76 The type of elements the TensorMapping acts on.