comparison src/LazyTensors/tensor_mapping.jl @ 370:8e55dee6a1a1

Merge branch refactor/remove_dynamic_size_tensormapping
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 28 Sep 2020 22:56:54 +0200
parents 7fe43d902a27
children cd509e57f898
comparison
equal deleted inserted replaced
366:0af6da238d95 370:8e55dee6a1a1
4 Describes a mapping of a D dimension tensor to an R dimension tensor. 4 Describes a mapping of a D dimension tensor to an R dimension tensor.
5 The action of the mapping is implemented through the method 5 The action of the mapping is implemented through the method
6 6
7 apply(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T} 7 apply(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
8 8
9 The size of range tensor should be dependent on the size of the domain tensor 9 The size of the range and domain that the operator works with should be returned by
10 and the type should implement the methods 10 the functions
11 11
12 range_size(::TensorMapping{T,R,D}, domain_size::NTuple{D,Integer}) where {T,R,D} 12 range_size(::TensorMapping)
13 domain_size(::TensorMapping{T,R,D}, range_size::NTuple{R,Integer}) where {T,R,D} 13 domain_size(::TensorMapping)
14 14
15 to allow querying for one or the other. 15 to allow querying for one or the other.
16 16
17 Optionally the action of the transpose may be defined through 17 Optionally the action of the transpose may be defined through
18 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T} 18 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
47 domain_dim(::TensorMapping{T,R,D}) where {T,R,D} = D 47 domain_dim(::TensorMapping{T,R,D}) where {T,R,D} = D
48 48
49 export range_dim, domain_dim 49 export range_dim, domain_dim
50 50
51 """ 51 """
52 range_size(M::TensorMapping, domain_size) 52 range_size(M::TensorMapping)
53 53
54 Return the resulting range size for the mapping applied to a given domain_size 54 Return the range size for the mapping.
55 """ 55 """
56 function range_size end 56 function range_size end
57 57
58 """ 58 """
59 domain_size(M::TensorMapping, range_size) 59 domain_size(M::TensorMapping)
60 60
61 Return the resulting domain size for the mapping applied to a given range_size 61 Return the domain size for the mapping.
62 """ 62 """
63 function domain_size end 63 function domain_size end
64 64
65 """ 65 export range_size, domain_size
66 Dummy type for representing dimensions of tensormappings when domain_size is unknown
67 """
68 struct UnknownDim end
69 export range_size, domain_size, TensorMappingDim, UnknownDim
70 66
71 # TODO: Think about boundschecking! 67 # TODO: Think about boundschecking!
72
73
74 """
75 TensorOperator{T,D}
76
77 A `TensorMapping{T,D,D}` where the range and domain tensor have the same number of
78 dimensions and the same size.
79 """
80 abstract type TensorOperator{T,D} <: TensorMapping{T,D,D} end
81 export TensorOperator
82 domain_size(::TensorOperator{T,D}, range_size::NTuple{D,Integer}) where {T,D} = range_size
83 range_size(::TensorOperator{T,D}, domain_size::NTuple{D,Integer}) where {T,D} = domain_size