@@ -114,23 +114,32 @@ function __interlace_bandwidths_square(ops::Diagonal, bw = __interlace_ops_bandw
114
114
l,u
115
115
end
116
116
117
+ # this is a hack to get constant-propagation in the indexing operation
118
+ _first (A) = A[1 ]
119
+ _second (A) = A[2 ]
120
+
121
+ _first (A:: Diagonal ) = parent (A)[1 ]
122
+ _second (A:: Diagonal ) = zero (eltype (A))
123
+
124
+ issquare (A) = size (A,1 ) == size (A,2 )
125
+ issquare (A:: Diagonal ) = true
126
+
117
127
Base. @constprop :aggressive function interlace_bandwidths (ops:: AbstractMatrix{<:Operator} ,
118
128
ds, rs,
119
129
allbanded = all (isbanded, ops),
120
130
bw = allbanded ? __interlace_ops_bandwidths (ops) : nothing )
121
131
122
- p= size (ops,1 )
123
132
dsi = interlacer (ds)
124
133
rsi = interlacer (rs)
125
134
126
- if size (ops, 2 ) == p && allbanded && # only support blocksize (1,) for now
135
+ if issquare (ops) && allbanded && # only support blocksize (1,) for now
127
136
all (i-> isa (i,AbstractFill) && getindex_value (i) == 1 , dsi. blocks) &&
128
137
all (i-> isa (i,AbstractFill) && getindex_value (i) == 1 , rsi. blocks)
129
138
130
139
l,u = __interlace_bandwidths_square (ops, bw)
131
- elseif p == 1 && size (ops,2 ) == 2 && size (ops[ 1 ] ,2 ) == 1
140
+ elseif size (ops, 1 ) == 1 && size (ops,2 ) == 2 && size (_first ( ops) ,2 ) == 1
132
141
# special case for example
133
- l,u = max (bandwidth (ops[ 1 ] ,1 ),bandwidth (ops[ 2 ] ,1 )- 1 ),bandwidth (ops[ 2 ] ,2 )+ 1
142
+ l,u = max (bandwidth (_first ( ops) ,1 ),bandwidth (_second ( ops) ,1 )- 1 ),bandwidth (_second ( ops) ,2 )+ 1
134
143
else
135
144
l,u = (dimension (rs)- 1 ,dimension (ds)- 1 ) # not banded
136
145
end
0 commit comments