This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 579 | Differences between
and this patch

Collapse All | Expand All

(-)a/Eigen/src/plugins/BlockMethods.h (-200 / +145 lines)
Lines 88-125 Link Here
88
  return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols);
88
  return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols);
89
}
89
}
90
90
91
/** \returns an expression of a fixed-size top-right corner of *this.
92
  *
93
  * \tparam CRows the number of rows in the corner
94
  * \tparam CCols the number of columns in the corner
95
  *
96
  * Example: \include MatrixBase_template_int_int_topRightCorner.cpp
97
  * Output: \verbinclude MatrixBase_template_int_int_topRightCorner.out
98
  *
99
  * \sa class Block, block<int,int>(Index,Index)
100
  */
101
template<int CRows, int CCols>
102
inline Block<Derived, CRows, CCols> topRightCorner()
103
{
104
  return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
105
}
106
107
/** This is the const version of topRightCorner<int, int>().*/
108
template<int CRows, int CCols>
109
inline const Block<const Derived, CRows, CCols> topRightCorner() const
110
{
111
  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols);
112
}
113
114
/** \returns an expression of a top-right corner of *this.
91
/** \returns an expression of a top-right corner of *this.
115
  *
92
  *
116
  * \tparam CRows number of rows in corner as specified at compile time
93
  * \tparam CRows number of rows in corner as specified at compile-time
117
  * \tparam CCols number of columns in corner as specified at compile time
94
  * \tparam CCols number of columns in corner as specified at compile-time
118
  * \param  cRows number of rows in corner as specified at run time
95
  * \param  cRows number of rows in corner as specified at run-time
119
  * \param  cCols number of columns in corner as specified at run time
96
  * \param  cCols number of columns in corner as specified at run-time
120
  *
97
  *
121
  * This function is mainly useful for corners where the number of rows is specified at compile time
98
  * This function is mainly useful for corners where the number of rows is specified at compile-time
122
  * and the number of columns is specified at run time, or vice versa. The compile-time and run-time
99
  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
123
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
100
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
124
  * \a CRows is \a Dynamic, and the same for the number of columns.
101
  * \a CRows is \a Dynamic, and the same for the number of columns.
125
  *
102
  *
Lines 129-142 Link Here
129
  * \sa class Block
106
  * \sa class Block
130
  */
107
  */
131
template<int CRows, int CCols>
108
template<int CRows, int CCols>
132
inline Block<Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols)
109
inline Block<Derived, CRows, CCols> topRightCorner(Index cRows = CRows, Index cCols = CCols)
133
{
110
{
134
  return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
111
  return Block<Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
135
}
112
}
136
113
137
/** This is the const version of topRightCorner<int, int>(Index, Index).*/
114
/** This is the const version of topRightCorner<int, int>(Index, Index).*/
138
template<int CRows, int CCols>
115
template<int CRows, int CCols>
139
inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows, Index cCols) const
116
inline const Block<const Derived, CRows, CCols> topRightCorner(Index cRows = CRows, Index cCols = CCols) const
140
{
117
{
141
  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
118
  return Block<const Derived, CRows, CCols>(derived(), 0, cols() - cCols, cRows, cCols);
142
}
119
}
Lines 164-200 Link Here
164
  return Block<const Derived>(derived(), 0, 0, cRows, cCols);
141
  return Block<const Derived>(derived(), 0, 0, cRows, cCols);
165
}
142
}
166
143
167
/** \returns an expression of a fixed-size top-left corner of *this.
168
  *
169
  * The template parameters CRows and CCols are the number of rows and columns in the corner.
170
  *
171
  * Example: \include MatrixBase_template_int_int_topLeftCorner.cpp
172
  * Output: \verbinclude MatrixBase_template_int_int_topLeftCorner.out
173
  *
174
  * \sa class Block, block(Index,Index,Index,Index)
175
  */
176
template<int CRows, int CCols>
177
inline Block<Derived, CRows, CCols> topLeftCorner()
178
{
179
  return Block<Derived, CRows, CCols>(derived(), 0, 0);
180
}
181
182
/** This is the const version of topLeftCorner<int, int>().*/
183
template<int CRows, int CCols>
184
inline const Block<const Derived, CRows, CCols> topLeftCorner() const
185
{
186
  return Block<const Derived, CRows, CCols>(derived(), 0, 0);
187
}
188
189
/** \returns an expression of a top-left corner of *this.
144
/** \returns an expression of a top-left corner of *this.
190
  *
145
  *
191
  * \tparam CRows number of rows in corner as specified at compile time
146
  * \tparam CRows number of rows in corner as specified at compile-time
192
  * \tparam CCols number of columns in corner as specified at compile time
147
  * \tparam CCols number of columns in corner as specified at compile-time
193
  * \param  cRows number of rows in corner as specified at run time
148
  * \param  cRows number of rows in corner as specified at run-time
194
  * \param  cCols number of columns in corner as specified at run time
149
  * \param  cCols number of columns in corner as specified at run-time
195
  *
150
  *
196
  * This function is mainly useful for corners where the number of rows is specified at compile time
151
  * This function is mainly useful for corners where the number of rows is specified at compile-time
197
  * and the number of columns is specified at run time, or vice versa. The compile-time and run-time
152
  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
198
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
153
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
199
  * \a CRows is \a Dynamic, and the same for the number of columns.
154
  * \a CRows is \a Dynamic, and the same for the number of columns.
200
  *
155
  *
Lines 204-217 Link Here
204
  * \sa class Block
159
  * \sa class Block
205
  */
160
  */
206
template<int CRows, int CCols>
161
template<int CRows, int CCols>
207
inline Block<Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols)
162
inline Block<Derived, CRows, CCols> topLeftCorner(Index cRows = CRows, Index cCols = CCols)
208
{
163
{
209
  return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
164
  return Block<Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
210
}
165
}
211
166
212
/** This is the const version of topLeftCorner<int, int>(Index, Index).*/
167
/** This is the const version of topLeftCorner<int, int>(Index, Index).*/
213
template<int CRows, int CCols>
168
template<int CRows, int CCols>
214
inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows, Index cCols) const
169
inline const Block<const Derived, CRows, CCols> topLeftCorner(Index cRows = CRows, Index cCols = CCols) const
215
{
170
{
216
  return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
171
  return Block<const Derived, CRows, CCols>(derived(), 0, 0, cRows, cCols);
217
}
172
}
Lines 239-275 Link Here
239
  return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
194
  return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
240
}
195
}
241
196
242
/** \returns an expression of a fixed-size bottom-right corner of *this.
243
  *
244
  * The template parameters CRows and CCols are the number of rows and columns in the corner.
245
  *
246
  * Example: \include MatrixBase_template_int_int_bottomRightCorner.cpp
247
  * Output: \verbinclude MatrixBase_template_int_int_bottomRightCorner.out
248
  *
249
  * \sa class Block, block(Index,Index,Index,Index)
250
  */
251
template<int CRows, int CCols>
252
inline Block<Derived, CRows, CCols> bottomRightCorner()
253
{
254
  return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
255
}
256
257
/** This is the const version of bottomRightCorner<int, int>().*/
258
template<int CRows, int CCols>
259
inline const Block<const Derived, CRows, CCols> bottomRightCorner() const
260
{
261
  return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
262
}
263
264
/** \returns an expression of a bottom-right corner of *this.
197
/** \returns an expression of a bottom-right corner of *this.
265
  *
198
  *
266
  * \tparam CRows number of rows in corner as specified at compile time
199
  * \tparam CRows number of rows in corner as specified at compile-time
267
  * \tparam CCols number of columns in corner as specified at compile time
200
  * \tparam CCols number of columns in corner as specified at compile-time
268
  * \param  cRows number of rows in corner as specified at run time
201
  * \param  cRows number of rows in corner as specified at run-time
269
  * \param  cCols number of columns in corner as specified at run time
202
  * \param  cCols number of columns in corner as specified at run-time
270
  *
203
  *
271
  * This function is mainly useful for corners where the number of rows is specified at compile time
204
  * This function is mainly useful for corners where the number of rows is specified at compile-time
272
  * and the number of columns is specified at run time, or vice versa. The compile-time and run-time
205
  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
273
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
206
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
274
  * \a CRows is \a Dynamic, and the same for the number of columns.
207
  * \a CRows is \a Dynamic, and the same for the number of columns.
275
  *
208
  *
Lines 279-292 Link Here
279
  * \sa class Block
212
  * \sa class Block
280
  */
213
  */
281
template<int CRows, int CCols>
214
template<int CRows, int CCols>
282
inline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols)
215
inline Block<Derived, CRows, CCols> bottomRightCorner(Index cRows = CRows, Index cCols = CCols)
283
{
216
{
284
  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
217
  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
285
}
218
}
286
219
287
/** This is the const version of bottomRightCorner<int, int>(Index, Index).*/
220
/** This is the const version of bottomRightCorner<int, int>(Index, Index).*/
288
template<int CRows, int CCols>
221
template<int CRows, int CCols>
289
inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows, Index cCols) const
222
inline const Block<const Derived, CRows, CCols> bottomRightCorner(Index cRows = CRows, Index cCols = CCols) const
290
{
223
{
291
  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
224
  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
292
}
225
}
Lines 314-350 Link Here
314
  return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols);
247
  return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols);
315
}
248
}
316
249
317
/** \returns an expression of a fixed-size bottom-left corner of *this.
318
  *
319
  * The template parameters CRows and CCols are the number of rows and columns in the corner.
320
  *
321
  * Example: \include MatrixBase_template_int_int_bottomLeftCorner.cpp
322
  * Output: \verbinclude MatrixBase_template_int_int_bottomLeftCorner.out
323
  *
324
  * \sa class Block, block(Index,Index,Index,Index)
325
  */
326
template<int CRows, int CCols>
327
inline Block<Derived, CRows, CCols> bottomLeftCorner()
328
{
329
  return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
330
}
331
332
/** This is the const version of bottomLeftCorner<int, int>().*/
333
template<int CRows, int CCols>
334
inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
335
{
336
  return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0);
337
}
338
339
/** \returns an expression of a bottom-left corner of *this.
250
/** \returns an expression of a bottom-left corner of *this.
340
  *
251
  *
341
  * \tparam CRows number of rows in corner as specified at compile time
252
  * \tparam CRows number of rows in corner as specified at compile-time
342
  * \tparam CCols number of columns in corner as specified at compile time
253
  * \tparam CCols number of columns in corner as specified at compile-time
343
  * \param  cRows number of rows in corner as specified at run time
254
  * \param  cRows number of rows in corner as specified at run-time
344
  * \param  cCols number of columns in corner as specified at run time
255
  * \param  cCols number of columns in corner as specified at run-time
345
  *
256
  *
346
  * This function is mainly useful for corners where the number of rows is specified at compile time
257
  * This function is mainly useful for corners where the number of rows is specified at compile-time
347
  * and the number of columns is specified at run time, or vice versa. The compile-time and run-time
258
  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
348
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
259
  * information should not contradict. In other words, \a cRows should equal \a CRows unless
349
  * \a CRows is \a Dynamic, and the same for the number of columns.
260
  * \a CRows is \a Dynamic, and the same for the number of columns.
350
  *
261
  *
Lines 354-367 Link Here
354
  * \sa class Block
265
  * \sa class Block
355
  */
266
  */
356
template<int CRows, int CCols>
267
template<int CRows, int CCols>
357
inline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols)
268
inline Block<Derived, CRows, CCols> bottomLeftCorner(Index cRows = CRows, Index cCols = CCols)
358
{
269
{
359
  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
270
  return Block<Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
360
}
271
}
361
272
362
/** This is the const version of bottomLeftCorner<int, int>(Index, Index).*/
273
/** This is the const version of bottomLeftCorner<int, int>(Index, Index).*/
363
template<int CRows, int CCols>
274
template<int CRows, int CCols>
364
inline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows, Index cCols) const
275
inline const Block<const Derived, CRows, CCols> bottomLeftCorner(Index cRows = CRows, Index cCols = CCols) const
365
{
276
{
366
  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
277
  return Block<const Derived, CRows, CCols>(derived(), rows() - cRows, 0, cRows, cCols);
367
}
278
}
Lines 390-396 Link Here
390
301
391
/** \returns a block consisting of the top rows of *this.
302
/** \returns a block consisting of the top rows of *this.
392
  *
303
  *
393
  * \tparam N the number of rows in the block
304
  * \tparam N the number of rows in the block as specified at compile-time
305
  * \param n the number of rows in the block as specified at run-time
306
  *
307
  * The compile-time and run-time information should not contradict. In other words,
308
  * \a n should equal \a N unless \a N is \a Dynamic.
394
  *
309
  *
395
  * Example: \include MatrixBase_template_int_topRows.cpp
310
  * Example: \include MatrixBase_template_int_topRows.cpp
396
  * Output: \verbinclude MatrixBase_template_int_topRows.out
311
  * Output: \verbinclude MatrixBase_template_int_topRows.out
Lines 398-413 Link Here
398
  * \sa class Block, block(Index,Index,Index,Index)
313
  * \sa class Block, block(Index,Index,Index,Index)
399
  */
314
  */
400
template<int N>
315
template<int N>
401
inline typename NRowsBlockXpr<N>::Type topRows()
316
inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
402
{
317
{
403
  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols());
318
  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
404
}
319
}
405
320
406
/** This is the const version of topRows<int>().*/
321
/** This is the const version of topRows<int>().*/
407
template<int N>
322
template<int N>
408
inline typename ConstNRowsBlockXpr<N>::Type topRows() const
323
inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
409
{
324
{
410
  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols());
325
  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
411
}
326
}
412
327
413
328
Lines 434-440 Link Here
434
349
435
/** \returns a block consisting of the bottom rows of *this.
350
/** \returns a block consisting of the bottom rows of *this.
436
  *
351
  *
437
  * \tparam N the number of rows in the block
352
  * \tparam N the number of rows in the block as specified at compile-time
353
  * \param n the number of rows in the block as specified at run-time
354
  *
355
  * The compile-time and run-time information should not contradict. In other words,
356
  * \a n should equal \a N unless \a N is \a Dynamic.
438
  *
357
  *
439
  * Example: \include MatrixBase_template_int_bottomRows.cpp
358
  * Example: \include MatrixBase_template_int_bottomRows.cpp
440
  * Output: \verbinclude MatrixBase_template_int_bottomRows.out
359
  * Output: \verbinclude MatrixBase_template_int_bottomRows.out
Lines 442-457 Link Here
442
  * \sa class Block, block(Index,Index,Index,Index)
361
  * \sa class Block, block(Index,Index,Index,Index)
443
  */
362
  */
444
template<int N>
363
template<int N>
445
inline typename NRowsBlockXpr<N>::Type bottomRows()
364
inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
446
{
365
{
447
  return typename NRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols());
366
  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
448
}
367
}
449
368
450
/** This is the const version of bottomRows<int>().*/
369
/** This is the const version of bottomRows<int>().*/
451
template<int N>
370
template<int N>
452
inline typename ConstNRowsBlockXpr<N>::Type bottomRows() const
371
inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
453
{
372
{
454
  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols());
373
  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
455
}
374
}
456
375
457
376
Lines 459-486 Link Here
459
/** \returns a block consisting of a range of rows of *this.
378
/** \returns a block consisting of a range of rows of *this.
460
  *
379
  *
461
  * \param startRow the index of the first row in the block
380
  * \param startRow the index of the first row in the block
462
  * \param numRows the number of rows in the block
381
  * \param n the number of rows in the block
463
  *
382
  *
464
  * Example: \include DenseBase_middleRows_int.cpp
383
  * Example: \include DenseBase_middleRows_int.cpp
465
  * Output: \verbinclude DenseBase_middleRows_int.out
384
  * Output: \verbinclude DenseBase_middleRows_int.out
466
  *
385
  *
467
  * \sa class Block, block(Index,Index,Index,Index)
386
  * \sa class Block, block(Index,Index,Index,Index)
468
  */
387
  */
469
inline RowsBlockXpr middleRows(Index startRow, Index numRows)
388
inline RowsBlockXpr middleRows(Index startRow, Index n)
470
{
389
{
471
  return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
390
  return RowsBlockXpr(derived(), startRow, 0, n, cols());
472
}
391
}
473
392
474
/** This is the const version of middleRows(Index,Index).*/
393
/** This is the const version of middleRows(Index,Index).*/
475
inline ConstRowsBlockXpr middleRows(Index startRow, Index numRows) const
394
inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
476
{
395
{
477
  return ConstRowsBlockXpr(derived(), startRow, 0, numRows, cols());
396
  return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
478
}
397
}
479
398
480
/** \returns a block consisting of a range of rows of *this.
399
/** \returns a block consisting of a range of rows of *this.
481
  *
400
  *
482
  * \tparam N the number of rows in the block
401
  * \tparam N the number of rows in the block as specified at compile-time
483
  * \param startRow the index of the first row in the block
402
  * \param startRow the index of the first row in the block
403
  * \param n the number of rows in the block as specified at run-time
404
  *
405
  * The compile-time and run-time information should not contradict. In other words,
406
  * \a n should equal \a N unless \a N is \a Dynamic.
484
  *
407
  *
485
  * Example: \include DenseBase_template_int_middleRows.cpp
408
  * Example: \include DenseBase_template_int_middleRows.cpp
486
  * Output: \verbinclude DenseBase_template_int_middleRows.out
409
  * Output: \verbinclude DenseBase_template_int_middleRows.out
Lines 488-503 Link Here
488
  * \sa class Block, block(Index,Index,Index,Index)
411
  * \sa class Block, block(Index,Index,Index,Index)
489
  */
412
  */
490
template<int N>
413
template<int N>
491
inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow)
414
inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
492
{
415
{
493
  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
416
  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
494
}
417
}
495
418
496
/** This is the const version of middleRows<int>().*/
419
/** This is the const version of middleRows<int>().*/
497
template<int N>
420
template<int N>
498
inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow) const
421
inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
499
{
422
{
500
  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
423
  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
501
}
424
}
502
425
503
426
Lines 524-530 Link Here
524
447
525
/** \returns a block consisting of the left columns of *this.
448
/** \returns a block consisting of the left columns of *this.
526
  *
449
  *
527
  * \tparam N the number of columns in the block
450
  * \tparam N the number of columns in the block as specified at compile-time
451
  * \param n the number of columns in the block as specified at run-time
452
  *
453
  * The compile-time and run-time information should not contradict. In other words,
454
  * \a n should equal \a N unless \a N is \a Dynamic.
528
  *
455
  *
529
  * Example: \include MatrixBase_template_int_leftCols.cpp
456
  * Example: \include MatrixBase_template_int_leftCols.cpp
530
  * Output: \verbinclude MatrixBase_template_int_leftCols.out
457
  * Output: \verbinclude MatrixBase_template_int_leftCols.out
Lines 532-547 Link Here
532
  * \sa class Block, block(Index,Index,Index,Index)
459
  * \sa class Block, block(Index,Index,Index,Index)
533
  */
460
  */
534
template<int N>
461
template<int N>
535
inline typename NColsBlockXpr<N>::Type leftCols()
462
inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
536
{
463
{
537
  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N);
464
  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
538
}
465
}
539
466
540
/** This is the const version of leftCols<int>().*/
467
/** This is the const version of leftCols<int>().*/
541
template<int N>
468
template<int N>
542
inline typename ConstNColsBlockXpr<N>::Type leftCols() const
469
inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
543
{
470
{
544
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N);
471
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
545
}
472
}
546
473
547
474
Lines 568-574 Link Here
568
495
569
/** \returns a block consisting of the right columns of *this.
496
/** \returns a block consisting of the right columns of *this.
570
  *
497
  *
571
  * \tparam N the number of columns in the block
498
  * \tparam N the number of columns in the block as specified at compile-time
499
  * \param n the number of columns in the block as specified at run-time
500
  *
501
  * The compile-time and run-time information should not contradict. In other words,
502
  * \a n should equal \a N unless \a N is \a Dynamic.
572
  *
503
  *
573
  * Example: \include MatrixBase_template_int_rightCols.cpp
504
  * Example: \include MatrixBase_template_int_rightCols.cpp
574
  * Output: \verbinclude MatrixBase_template_int_rightCols.out
505
  * Output: \verbinclude MatrixBase_template_int_rightCols.out
Lines 576-591 Link Here
576
  * \sa class Block, block(Index,Index,Index,Index)
507
  * \sa class Block, block(Index,Index,Index,Index)
577
  */
508
  */
578
template<int N>
509
template<int N>
579
inline typename NColsBlockXpr<N>::Type rightCols()
510
inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
580
{
511
{
581
  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
512
  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
582
}
513
}
583
514
584
/** This is the const version of rightCols<int>().*/
515
/** This is the const version of rightCols<int>().*/
585
template<int N>
516
template<int N>
586
inline typename ConstNColsBlockXpr<N>::Type rightCols() const
517
inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
587
{
518
{
588
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
519
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
589
}
520
}
590
521
591
522
Lines 613-620 Link Here
613
544
614
/** \returns a block consisting of a range of columns of *this.
545
/** \returns a block consisting of a range of columns of *this.
615
  *
546
  *
616
  * \tparam N the number of columns in the block
547
  * \tparam N the number of columns in the block as specified at compile-time
617
  * \param startCol the index of the first column in the block
548
  * \param startCol the index of the first column in the block
549
  * \param n the number of columns in the block as specified at run-time
550
  *
551
  * The compile-time and run-time information should not contradict. In other words,
552
  * \a n should equal \a N unless \a N is \a Dynamic.
618
  *
553
  *
619
  * Example: \include DenseBase_template_int_middleCols.cpp
554
  * Example: \include DenseBase_template_int_middleCols.cpp
620
  * Output: \verbinclude DenseBase_template_int_middleCols.out
555
  * Output: \verbinclude DenseBase_template_int_middleCols.out
Lines 622-637 Link Here
622
  * \sa class Block, block(Index,Index,Index,Index)
557
  * \sa class Block, block(Index,Index,Index,Index)
623
  */
558
  */
624
template<int N>
559
template<int N>
625
inline typename NColsBlockXpr<N>::Type middleCols(Index startCol)
560
inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
626
{
561
{
627
  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
562
  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
628
}
563
}
629
564
630
/** This is the const version of middleCols<int>().*/
565
/** This is the const version of middleCols<int>().*/
631
template<int N>
566
template<int N>
632
inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol) const
567
inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
633
{
568
{
634
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
569
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
635
}
570
}
636
571
637
572
Lines 667-681 Link Here
667
602
668
/** \returns an expression of a block in *this.
603
/** \returns an expression of a block in *this.
669
  *
604
  *
670
  * \tparam BlockRows number of rows in block as specified at compile time
605
  * \tparam BlockRows number of rows in block as specified at compile-time
671
  * \tparam BlockCols number of columns in block as specified at compile time
606
  * \tparam BlockCols number of columns in block as specified at compile-time
672
  * \param  startRow  the first row in the block
607
  * \param  startRow  the first row in the block
673
  * \param  startCol  the first column in the block
608
  * \param  startCol  the first column in the block
674
  * \param  blockRows number of rows in block as specified at run time
609
  * \param  blockRows number of rows in block as specified at run-time
675
  * \param  blockCols number of columns in block as specified at run time
610
  * \param  blockCols number of columns in block as specified at run-time
676
  *
611
  *
677
  * This function is mainly useful for blocks where the number of rows is specified at compile time
612
  * This function is mainly useful for blocks where the number of rows is specified at compile-time
678
  * and the number of columns is specified at run time, or vice versa. The compile-time and run-time
613
  * and the number of columns is specified at run-time, or vice versa. The compile-time and run-time
679
  * information should not contradict. In other words, \a blockRows should equal \a BlockRows unless
614
  * information should not contradict. In other words, \a blockRows should equal \a BlockRows unless
680
  * \a BlockRows is \a Dynamic, and the same for the number of columns.
615
  * \a BlockRows is \a Dynamic, and the same for the number of columns.
681
  *
616
  *
Lines 738-744 Link Here
738
  * \only_for_vectors
673
  * \only_for_vectors
739
  *
674
  *
740
  * \param start the first coefficient in the segment
675
  * \param start the first coefficient in the segment
741
  * \param vecSize the number of coefficients in the segment
676
  * \param n the number of coefficients in the segment
742
  *
677
  *
743
  * Example: \include MatrixBase_segment_int_int.cpp
678
  * Example: \include MatrixBase_segment_int_int.cpp
744
  * Output: \verbinclude MatrixBase_segment_int_int.out
679
  * Output: \verbinclude MatrixBase_segment_int_int.out
Lines 749-773 Link Here
749
  *
684
  *
750
  * \sa class Block, segment(Index)
685
  * \sa class Block, segment(Index)
751
  */
686
  */
752
inline SegmentReturnType segment(Index start, Index vecSize)
687
inline SegmentReturnType segment(Index start, Index n)
753
{
688
{
754
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
689
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
755
  return SegmentReturnType(derived(), start, vecSize);
690
  return SegmentReturnType(derived(), start, n);
756
}
691
}
757
692
758
693
759
/** This is the const version of segment(Index,Index).*/
694
/** This is the const version of segment(Index,Index).*/
760
inline ConstSegmentReturnType segment(Index start, Index vecSize) const
695
inline ConstSegmentReturnType segment(Index start, Index n) const
761
{
696
{
762
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
697
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
763
  return ConstSegmentReturnType(derived(), start, vecSize);
698
  return ConstSegmentReturnType(derived(), start, n);
764
}
699
}
765
700
766
/** \returns a dynamic-size expression of the first coefficients of *this.
701
/** \returns a dynamic-size expression of the first coefficients of *this.
767
  *
702
  *
768
  * \only_for_vectors
703
  * \only_for_vectors
769
  *
704
  *
770
  * \param vecSize the number of coefficients in the block
705
  * \param n the number of coefficients in the segment
771
  *
706
  *
772
  * Example: \include MatrixBase_start_int.cpp
707
  * Example: \include MatrixBase_start_int.cpp
773
  * Output: \verbinclude MatrixBase_start_int.out
708
  * Output: \verbinclude MatrixBase_start_int.out
Lines 778-802 Link Here
778
  *
713
  *
779
  * \sa class Block, block(Index,Index)
714
  * \sa class Block, block(Index,Index)
780
  */
715
  */
781
inline SegmentReturnType head(Index vecSize)
716
inline SegmentReturnType head(Index n)
782
{
717
{
783
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
718
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
784
  return SegmentReturnType(derived(), 0, vecSize);
719
  return SegmentReturnType(derived(), 0, n);
785
}
720
}
786
721
787
/** This is the const version of head(Index).*/
722
/** This is the const version of head(Index).*/
788
inline ConstSegmentReturnType
723
inline ConstSegmentReturnType head(Index n) const
789
  head(Index vecSize) const
790
{
724
{
791
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
725
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
792
  return ConstSegmentReturnType(derived(), 0, vecSize);
726
  return ConstSegmentReturnType(derived(), 0, n);
793
}
727
}
794
728
795
/** \returns a dynamic-size expression of the last coefficients of *this.
729
/** \returns a dynamic-size expression of the last coefficients of *this.
796
  *
730
  *
797
  * \only_for_vectors
731
  * \only_for_vectors
798
  *
732
  *
799
  * \param vecSize the number of coefficients in the block
733
  * \param n the number of coefficients in the segment
800
  *
734
  *
801
  * Example: \include MatrixBase_end_int.cpp
735
  * Example: \include MatrixBase_end_int.cpp
802
  * Output: \verbinclude MatrixBase_end_int.out
736
  * Output: \verbinclude MatrixBase_end_int.out
Lines 807-901 Link Here
807
  *
741
  *
808
  * \sa class Block, block(Index,Index)
742
  * \sa class Block, block(Index,Index)
809
  */
743
  */
810
inline SegmentReturnType tail(Index vecSize)
744
inline SegmentReturnType tail(Index n)
811
{
745
{
812
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
746
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
813
  return SegmentReturnType(derived(), this->size() - vecSize, vecSize);
747
  return SegmentReturnType(derived(), this->size() - n, n);
814
}
748
}
815
749
816
/** This is the const version of tail(Index).*/
750
/** This is the const version of tail(Index).*/
817
inline ConstSegmentReturnType tail(Index vecSize) const
751
inline ConstSegmentReturnType tail(Index n) const
818
{
752
{
819
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
753
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
820
  return ConstSegmentReturnType(derived(), this->size() - vecSize, vecSize);
754
  return ConstSegmentReturnType(derived(), this->size() - n, n);
821
}
755
}
822
756
823
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
757
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
824
  *
758
  *
825
  * \only_for_vectors
759
  * \only_for_vectors
826
  *
760
  *
827
  * The template parameter \a Size is the number of coefficients in the block
761
  * \tparam N the number of coefficients in the segment as specified at compile-time
762
  * \param start the index of the first element in the segment
763
  * \param n the number of coefficients in the segment as specified at compile-time
828
  *
764
  *
829
  * \param start the index of the first element of the sub-vector
765
  * The compile-time and run-time information should not contradict. In other words,
766
  * \a n should equal \a N unless \a N is \a Dynamic.
830
  *
767
  *
831
  * Example: \include MatrixBase_template_int_segment.cpp
768
  * Example: \include MatrixBase_template_int_segment.cpp
832
  * Output: \verbinclude MatrixBase_template_int_segment.out
769
  * Output: \verbinclude MatrixBase_template_int_segment.out
833
  *
770
  *
834
  * \sa class Block
771
  * \sa class Block
835
  */
772
  */
836
template<int Size>
773
template<int N>
837
inline typename FixedSegmentReturnType<Size>::Type segment(Index start)
774
inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
838
{
775
{
839
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
776
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
840
  return typename FixedSegmentReturnType<Size>::Type(derived(), start);
777
  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
841
}
778
}
842
779
843
/** This is the const version of segment<int>(Index).*/
780
/** This is the const version of segment<int>(Index).*/
844
template<int Size>
781
template<int N>
845
inline typename ConstFixedSegmentReturnType<Size>::Type segment(Index start) const
782
inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
846
{
783
{
847
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
784
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
848
  return typename ConstFixedSegmentReturnType<Size>::Type(derived(), start);
785
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
849
}
786
}
850
787
851
/** \returns a fixed-size expression of the first coefficients of *this.
788
/** \returns a fixed-size expression of the first coefficients of *this.
852
  *
789
  *
853
  * \only_for_vectors
790
  * \only_for_vectors
854
  *
791
  *
855
  * The template parameter \a Size is the number of coefficients in the block
792
  * \tparam N the number of coefficients in the segment as specified at compile-time
793
  * \param  n the number of coefficients in the segment as specified at run-time
794
  *
795
  * The compile-time and run-time information should not contradict. In other words,
796
  * \a n should equal \a N unless \a N is \a Dynamic.
856
  *
797
  *
857
  * Example: \include MatrixBase_template_int_start.cpp
798
  * Example: \include MatrixBase_template_int_start.cpp
858
  * Output: \verbinclude MatrixBase_template_int_start.out
799
  * Output: \verbinclude MatrixBase_template_int_start.out
859
  *
800
  *
860
  * \sa class Block
801
  * \sa class Block
861
  */
802
  */
862
template<int Size>
803
template<int N>
863
inline typename FixedSegmentReturnType<Size>::Type head()
804
inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
864
{
805
{
865
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
806
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
866
  return typename FixedSegmentReturnType<Size>::Type(derived(), 0);
807
  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
867
}
808
}
868
809
869
/** This is the const version of head<int>().*/
810
/** This is the const version of head<int>().*/
870
template<int Size>
811
template<int N>
871
inline typename ConstFixedSegmentReturnType<Size>::Type head() const
812
inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
872
{
813
{
873
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
814
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
874
  return typename ConstFixedSegmentReturnType<Size>::Type(derived(), 0);
815
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
875
}
816
}
876
817
877
/** \returns a fixed-size expression of the last coefficients of *this.
818
/** \returns a fixed-size expression of the last coefficients of *this.
878
  *
819
  *
879
  * \only_for_vectors
820
  * \only_for_vectors
880
  *
821
  *
881
  * The template parameter \a Size is the number of coefficients in the block
822
  * \tparam N the number of coefficients in the segment as specified at compile-time
823
  * \param  n the number of coefficients in the segment as specified at run-time
824
  *
825
  * The compile-time and run-time information should not contradict. In other words,
826
  * \a n should equal \a N unless \a N is \a Dynamic.
882
  *
827
  *
883
  * Example: \include MatrixBase_template_int_end.cpp
828
  * Example: \include MatrixBase_template_int_end.cpp
884
  * Output: \verbinclude MatrixBase_template_int_end.out
829
  * Output: \verbinclude MatrixBase_template_int_end.out
885
  *
830
  *
886
  * \sa class Block
831
  * \sa class Block
887
  */
832
  */
888
template<int Size>
833
template<int N>
889
inline typename FixedSegmentReturnType<Size>::Type tail()
834
inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
890
{
835
{
891
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
836
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
892
  return typename FixedSegmentReturnType<Size>::Type(derived(), size() - Size);
837
  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
893
}
838
}
894
839
895
/** This is the const version of tail<int>.*/
840
/** This is the const version of tail<int>.*/
896
template<int Size>
841
template<int N>
897
inline typename ConstFixedSegmentReturnType<Size>::Type tail() const
842
inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
898
{
843
{
899
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
844
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
900
  return typename ConstFixedSegmentReturnType<Size>::Type(derived(), size() - Size);
845
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
901
}
846
}

Return to bug 579