81
81
const VectorInterlaceOperator = InterlaceOperator{T,1 ,DS,RS} where {T,DS,RS<: Space{D,R} } where {D,R<: AbstractVector }
82
82
const MatrixInterlaceOperator = InterlaceOperator{T,2 ,DS,RS} where {T,DS,RS<: Space{D,R} } where {D,R<: AbstractVector }
83
83
84
+ @static if VERSION >= v " 1.8"
85
+ Base. @constprop :aggressive interlace_bandwidths (args... ) = _interlace_bandwidths (args... )
86
+ else
87
+ interlace_bandwidths (args... ) = _interlace_bandwidths (args... )
88
+ end
84
89
85
- function InterlaceOperator (ops:: AbstractMatrix{<:Operator} ,ds:: Space ,rs:: Space )
90
+ @inline function _interlace_bandwidths (ops:: AbstractMatrix{<:Operator} ,
91
+ ds, rs, allbanded = all (isbanded,ops))
86
92
# calculate bandwidths TODO : generalize
87
93
p= size (ops,1 )
88
94
dsi = interlacer (ds)
89
95
rsi = interlacer (rs)
90
96
91
- if size (ops,2 ) == p && all (isbanded,ops) && # only support blocksize (1,) for now
97
+ if size (ops,2 ) == p && allbanded && # only support blocksize (1,) for now
92
98
all (i-> isa (i,AbstractFill) && getindex_value (i) == 1 , dsi. blocks) &&
93
99
all (i-> isa (i,AbstractFill) && getindex_value (i) == 1 , rsi. blocks)
94
100
95
101
l,u = 0 ,0
96
- for k= 1 : p,j = 1 : p
102
+ for k= axes (ops, 1 ), j = axes (ops, 2 )
97
103
l= max (l,p* bandwidth (ops[k,j],1 )+ k- j)
98
104
end
99
- for k= 1 : p,j = 1 : p
105
+ for k= axes (ops, 1 ), j = axes (ops, 2 )
100
106
u= max (u,p* bandwidth (ops[k,j],2 )+ j- k)
101
107
end
102
108
elseif p == 1 && size (ops,2 ) == 2 && size (ops[1 ],2 ) == 1
@@ -105,20 +111,14 @@ function InterlaceOperator(ops::AbstractMatrix{<:Operator},ds::Space,rs::Space)
105
111
else
106
112
l,u = (1 - dimension (rs),dimension (ds)- 1 ) # not banded
107
113
end
108
-
109
- MT = Matrix{Operator{promote_eltypeof (ops)}}
110
- opsm = strictconvert (MT, ops)
111
- InterlaceOperator (opsm,ds,rs,
112
- cache (dsi),
113
- cache (rsi),
114
- (l,u))
114
+ l,u
115
115
end
116
116
117
-
118
- function InterlaceOperator (ops :: VectorOrTupleOfOp , ds :: Space , rs:: Space )
117
+ @inline function _interlace_bandwidths (ops :: VectorOrTupleOfOp ,
118
+ ds , rs, allbanded = all (isbanded,ops) )
119
119
# calculate bandwidths
120
120
p= size (ops,1 )
121
- if all (isbanded,ops)
121
+ if allbanded
122
122
l,u = 0 ,0
123
123
# TODO : this code assumes an interlace strategy that might not be right
124
124
for k= 1 : p
@@ -130,13 +130,33 @@ function InterlaceOperator(ops::VectorOrTupleOfOp, ds::Space, rs::Space)
130
130
else
131
131
l,u = (1 - dimension (rs),dimension (ds)- 1 ) # not banded
132
132
end
133
+ l,u
134
+ end
135
+
136
+ function InterlaceOperator (ops:: AbstractMatrix{<:Operator} , ds:: Space , rs:: Space ,
137
+ bw = interlace_bandwidths (ops, ds, rs))
138
+
139
+ dsi = interlacer (ds)
140
+ rsi = interlacer (rs)
141
+
142
+ MT = Matrix{Operator{promote_eltypeof (ops)}}
143
+ opsm = strictconvert (MT, ops)
144
+ InterlaceOperator (opsm,ds,rs,
145
+ cache (dsi),
146
+ cache (rsi),
147
+ bw)
148
+ end
149
+
150
+
151
+ function InterlaceOperator (ops:: VectorOrTupleOfOp , ds:: Space , rs:: Space ,
152
+ bw = interlace_bandwidths (ops, ds, rs))
133
153
134
154
VT = Vector{Operator{promote_eltypeof (ops)}}
135
155
opsv = strictconvert (VT, convert_vector (ops))
136
156
InterlaceOperator (opsv,ds,rs,
137
157
cache (BlockInterlacer (tuple (blocklengths (ds)))),
138
158
cache (interlacer (rs)),
139
- (l,u) )
159
+ bw )
140
160
end
141
161
142
162
interlace_domainspace (ops:: AbstractMatrix , :: Type{NoSpace} ) = domainspace (ops)
0 commit comments