@@ -108,19 +108,25 @@ function view(A::Operator,kr::UnitRange,jr::UnitRange)
108
108
end
109
109
end
110
110
111
- view (A:: Operator ,:: Colon ,:: Colon ) = view (A,1 : size (A,1 ),1 : size (A,2 ))
112
- view (A:: Operator ,:: Colon ,jr) = view (A,1 : size (A,1 ),jr)
113
- view (A:: Operator ,kr,:: Colon ) = view (A,kr,1 : size (A,2 ))
114
-
115
-
116
- view (A:: Operator ,K:: Block ,J:: Block ) = SubOperator (A,(K,J))
117
- view (A:: Operator ,K:: Block ,j:: Colon ) = view (A,blockrows (A,K),j)
118
- view (A:: Operator ,k:: Colon ,J:: Block ) = view (A,k,blockcols (A,J))
119
- view (A:: Operator , K:: Block , j) = view (A,blockrows (A,Int (K)),j)
120
- view (A:: Operator , k, J:: Block ) = view (A,k,blockcols (A,Int (J))) # TODO : fix view
121
- view (A:: Operator ,KR:: BlockRange ,JR:: BlockRange ) = SubOperator (A,(KR,JR))
111
+ _replace_inds (A, ax, inds:: Tuple{} , out, n) = out
112
+ function _replace_inds (A, ax, inds:: Tuple{Any, Vararg} , out, n)
113
+ outnew = (out... , inds[1 ])
114
+ _replace_inds (A, Base. tail (ax), Base. tail (inds), outnew, n+ 1 )
115
+ end
116
+ function _replace_inds (A, ax, inds:: Tuple{Colon, Vararg} , out, n)
117
+ outnew = (out... , ax[1 ])
118
+ _replace_inds (A, Base. tail (ax), Base. tail (inds), outnew, n+ 1 )
119
+ end
120
+ function _replace_inds (A, ax, inds:: Tuple{Block, Vararg} , out, n)
121
+ blkind = n == 1 ? blockrows (A, inds[1 ]) : n == 2 ? blockcols (A, inds[1 ]) : error (" invalid dimension " , n)
122
+ outnew = (out... , blkind)
123
+ _replace_inds (A, Base. tail (ax), Base. tail (inds), outnew, n+ 1 )
124
+ end
122
125
123
- view (A:: Operator ,k,j) = SubOperator (A,(k,j))
126
+ function view (A:: Operator , k, j)
127
+ inds = _replace_inds (A, axes (A), (k,j), (), 1 )
128
+ SubOperator (A, inds)
129
+ end
124
130
125
131
defaultgetindex (B:: Operator ,k:: InfRanges , j:: InfRanges ) = view (B, k, j)
126
132
defaultgetindex (B:: Operator ,k:: AbstractRange , j:: InfRanges ) = view (B, k, j)
0 commit comments