144{
145 Int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
147 assert(type == 'c' || type == 'r');
148 nbcol0 = (type ==
'c' ? ma->
nbcol : ma->
nbrow);
149 nbcol1 = (type ==
'c' ? mb->
nbcol : mb->
nbrow);
150 templatewidth0 = q0 * nbcol0;
151 templatewidth1 = q1 * nbcol1;
152 {
155 j0 =
SHIFT(col0, sp0, q0) * nbcol0 - ja;
156 j1 =
SHIFT(col1, sp1, q1) * nbcol1 - jb;
157 }
158 offset = 0;
159 l = 0;
160
161
162
163 assert(j0 + nbcol0 > 0);
164 assert(j1 + nbcol1 > 0);
165 while ((j0 < n) && (j1 < n)) {
168 end0 = j0 + nbcol0;
169 end1 = j1 + nbcol1;
170 if (end0 <= j1) {
171 j0 += templatewidth0;
172 l += nbcol0;
173 continue;
174 }
175 if (end1 <= j0) {
176 j1 += templatewidth1;
177 continue;
178 }
179
181 start =
max(start, 0);
182
183 result[offset].
lstart = l + start - j0;
184 end =
min(end0, end1);
185 if (end0 == end) {
186 j0 += templatewidth0;
187 l += nbcol0;
188 }
189 if (end1 == end)
190 j1 += templatewidth1;
191
193 assert(end > start);
194
195
196
197
198
199
200 result[offset].
len = end - start;
201 offset += 1;
202 }
203 return offset;
204}
#define SHIFT(row, sprow, nbrow)