comparison LazyTensors/src/tensor_mapping.jl @ 190:8964b3165097 boundary_conditions

Break LazyTensors.jl into several files
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 20 Jun 2019 22:48:07 +0200
parents
children e21dcda55163
comparison
equal deleted inserted replaced
189:e8e21db70112 190:8964b3165097
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 export range_size, domain_size
66 # TODO: Think about boundschecking!
67
68
69 """
70 TensorOperator{T,D}
71
72 A `TensorMapping{T,D,D}` where the range and domain tensor have the same number of
73 dimensions and the same size.
74 """
75 abstract type TensorOperator{T,D} <: TensorMapping{T,D,D} end
76 export TensorOperator
77 domain_size(::TensorOperator{T,D}, range_size::NTuple{D,Integer}) where {T,D} = range_size
78 range_size(::TensorOperator{T,D}, domain_size::NTuple{D,Integer}) where {T,D} = domain_size