@@ -17,11 +17,11 @@ factor(d::AbstractProductSpace,k) = factors(d)[k]
17
17
# tensor entry of a tensor product of d spaces
18
18
# findfirst is overriden to get efficient inverse
19
19
# blocklengths is a tuple of block lengths, e.g., Chebyshev()^2
20
- # would be Tensorizer((1:∞,1:∞ ))
20
+ # would be Tensorizer((Ones{Int}(∞), Ones{Int}(∞) ))
21
21
# ConstantSpace() ⊗ Chebyshev()
22
- # would be Tensorizer((1:1,1:∞ ))
22
+ # would be Tensorizer((1:1,Ones{Int}(∞) ))
23
23
# and Chebyshev() ⊗ ArraySpace([Chebyshev(),Chebyshev()])
24
- # would be Tensorizer((1:∞,2:2:∞ ))
24
+ # would be Tensorizer((Ones{Int}(∞), Fill(2,∞) ))
25
25
26
26
27
27
struct Tensorizer{DMS<: Tuple }
@@ -79,7 +79,7 @@ function next(a::TrivialTensorizer{d}, iterator_tuple) where {d}
79
79
end
80
80
81
81
82
- function done (a:: TrivialTensorizer , iterator_tuple)
82
+ function done (a:: TrivialTensorizer , iterator_tuple):: Bool
83
83
i, tot = last (iterator_tuple)
84
84
return i ≥ tot
85
85
end
89
89
start (a:: Tensorizer2D ) = _start (a)
90
90
start (a:: TrivialTensorizer{2} ) = _start (a)
91
91
92
- _start (a) = (1 ,1 ), ( 1 ,1 ), ( 0 ,0 ), ( a. blocks[1 ][1 ],a. blocks[2 ][1 ]), (0 ,length (a))
92
+ _start (a) = (1 ,1 , 1 ,1 , 0 ,0 , a. blocks[1 ][1 ],a. blocks[2 ][1 ]), (0 ,length (a))
93
93
94
- next (a:: Tensorizer2D , state) = _next (a, state)
95
- next (a:: TrivialTensorizer{2} , state) = _next (a, state)
94
+ next (a:: Tensorizer2D , state) = _next (a, state:: typeof ( _start (a)) )
95
+ next (a:: TrivialTensorizer{2} , state) = _next (a, state:: typeof ( _start (a)) )
96
96
97
- function _next (a, ((K,J), (k,j), (rsh,csh), (n,m), (i,tot)))
97
+ function _next (a, st)
98
+ (K,J, k,j, rsh,csh, n,m), (i,tot) = st
98
99
ret = k+ rsh,j+ csh
99
100
if k== n && j== m # end of block
100
101
if J == 1 || K == length (a. blocks[1 ]) # end of new block
@@ -115,13 +116,16 @@ function _next(a, ((K,J), (k,j), (rsh,csh), (n,m), (i,tot)))
115
116
else
116
117
k += 1
117
118
end
118
- ret, ((K,J), ( k,j), ( rsh,csh), ( n,m), (i+ 1 ,tot))
119
+ ret, ((K,J, k,j, rsh,csh, n,m), (i+ 1 ,tot))
119
120
end
120
121
121
- done (a:: Tensorizer2D , state) = _done (a, state)
122
- done (a:: TrivialTensorizer{2} , state) = _done (a, state)
122
+ done (a:: Tensorizer2D , state) = _done (a, state:: typeof ( _start (a)) )
123
+ done (a:: TrivialTensorizer{2} , state) = _done (a, state:: typeof ( _start (a)) )
123
124
124
- _done (a, (_, _, _, _, (i,tot))) = i ≥ tot
125
+ function _done (a, st):: Bool
126
+ i, tot = last (st)
127
+ i ≥ tot
128
+ end
125
129
126
130
iterate (a:: Tensorizer ) = next (a, start (a))
127
131
function iterate (a:: Tensorizer , st)
0 commit comments