comparison src/LazyTensors/lazy_tensor.jl @ 1858:4a9be96f2569 feature/documenter_logo

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 12 Jan 2025 21:18:44 +0100
parents dfb43fdac9fc
children
comparison
equal deleted inserted replaced
1857:ffde7dad9da5 1858:4a9be96f2569
1 """
2 LazyTensor{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 ```julia
7 apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
8 ```
9
10 The size of the range and domain that the operator works with should be returned by
11 the functions
12 ```julia
13 range_size(::LazyTensor)
14 domain_size(::LazyTensor)
15 ```
16 to allow querying for one or the other.
17
18 Optionally the action of the transpose may be defined through
19 ```julia
20 apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {R,D,T}
21 ```
22 """
23 abstract type LazyTensor{T,R,D} end
24
25 """
26 apply(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg) where {R,D,T}
27
28 Return the result of the mapping for a given index.
29 """
30 function apply end
31
32 """
33 apply_transpose(t::LazyTensor{T,R,D}, v::AbstractArray{<:Any,R}, I::Vararg) where {R,D,T}
34
35 Return the result of the transposed mapping for a given index.
36 """
37 function apply_transpose end
38
39 """
40 range_dim(::LazyTensor)
41 Return the dimension of the range space of a given mapping
42 """
43 range_dim(::LazyTensor{T,R,D}) where {T,R,D} = R
44
45 """
46 domain_dim(::LazyTensor)
47 Return the dimension of the domain space of a given mapping
48 """
49 domain_dim(::LazyTensor{T,R,D}) where {T,R,D} = D
50
51
52 """
53 range_size(M::LazyTensor)
54
55 Return the range size for the mapping.
56 """
57 function range_size end
58
59 """
60 domain_size(M::LazyTensor)
61
62 Return the domain size for the mapping.
63 """
64 function domain_size end
65
66
67 """
68 eltype(::LazyTensor{T})
69
70 The type of elements the LazyTensor acts on.
71 """
72 Base.eltype(::LazyTensor{T}) where T = T
73