comparison src/LazyTensors/tensor_mapping.jl @ 333:01b851161018 refactor/combine_to_one_package

Start converting to one package by moving all the files to their correct location
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 25 Sep 2020 13:06:02 +0200
parents LazyTensors/src/tensor_mapping.jl@e21dcda55163
children 7fe43d902a27
comparison
equal deleted inserted replaced
332:535f1bff4bcc 333:01b851161018
1 """
2 TensorMapping{T,R,D}
3
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
6
7 apply(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
8
9 The size of range tensor should be dependent on the size of the domain tensor
10 and the type should implement the methods
11
12 range_size(::TensorMapping{T,R,D}, domain_size::NTuple{D,Integer}) where {T,R,D}
13 domain_size(::TensorMapping{T,R,D}, range_size::NTuple{R,Integer}) where {T,R,D}
14
15 to allow querying for one or the other.
16
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}
19 """
20 abstract type TensorMapping{T,R,D} end
21 export TensorMapping
22
23 """
24 apply(t::TensorMapping{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
25
26 Return the result of the mapping for a given index.
27 """
28 function apply end
29 export apply
30
31 """
32 apply_transpose(t::TensorMapping{T,R,D}, v::AbstractArray{T,R}, I::Vararg) where {R,D,T}
33
34 Return the result of the transposed mapping for a given index.
35 """
36 function apply_transpose end
37 export apply_transpose
38
39 """
40 Return the dimension of the range space of a given mapping
41 """
42 range_dim(::TensorMapping{T,R,D}) where {T,R,D} = R
43
44 """
45 Return the dimension of the domain space of a given mapping
46 """
47 domain_dim(::TensorMapping{T,R,D}) where {T,R,D} = D
48
49 export range_dim, domain_dim
50
51 """
52 range_size(M::TensorMapping, domain_size)
53
54 Return the resulting range size for the mapping applied to a given domain_size
55 """
56 function range_size end
57
58 """
59 domain_size(M::TensorMapping, range_size)
60
61 Return the resulting domain size for the mapping applied to a given range_size
62 """
63 function domain_size end
64
65 """
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
71 # 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