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 (-103 / +137 lines)
Lines 113-125 Link Here
113
113
114
/** \returns an expression of a top-right corner of *this.
114
/** \returns an expression of a top-right corner of *this.
115
  *
115
  *
116
  * \tparam CRows number of rows in corner as specified at compile time
116
  * \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
117
  * \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
118
  * \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
119
  * \param  cCols number of columns in corner as specified at run-time
120
  *
120
  *
121
  * This function is mainly useful for corners where the number of rows is specified at compile time
121
  * 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
122
  * 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
123
  * 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.
124
  * \a CRows is \a Dynamic, and the same for the number of columns.
125
  *
125
  *
Lines 188-200 Link Here
188
188
189
/** \returns an expression of a top-left corner of *this.
189
/** \returns an expression of a top-left corner of *this.
190
  *
190
  *
191
  * \tparam CRows number of rows in corner as specified at compile time
191
  * \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
192
  * \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
193
  * \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
194
  * \param  cCols number of columns in corner as specified at run-time
195
  *
195
  *
196
  * This function is mainly useful for corners where the number of rows is specified at compile time
196
  * 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
197
  * 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
198
  * 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.
199
  * \a CRows is \a Dynamic, and the same for the number of columns.
200
  *
200
  *
Lines 263-275 Link Here
263
263
264
/** \returns an expression of a bottom-right corner of *this.
264
/** \returns an expression of a bottom-right corner of *this.
265
  *
265
  *
266
  * \tparam CRows number of rows in corner as specified at compile time
266
  * \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
267
  * \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
268
  * \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
269
  * \param  cCols number of columns in corner as specified at run-time
270
  *
270
  *
271
  * This function is mainly useful for corners where the number of rows is specified at compile time
271
  * 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
272
  * 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
273
  * 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.
274
  * \a CRows is \a Dynamic, and the same for the number of columns.
275
  *
275
  *
Lines 338-350 Link Here
338
338
339
/** \returns an expression of a bottom-left corner of *this.
339
/** \returns an expression of a bottom-left corner of *this.
340
  *
340
  *
341
  * \tparam CRows number of rows in corner as specified at compile time
341
  * \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
342
  * \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
343
  * \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
344
  * \param  cCols number of columns in corner as specified at run-time
345
  *
345
  *
346
  * This function is mainly useful for corners where the number of rows is specified at compile time
346
  * 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
347
  * 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
348
  * 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.
349
  * \a CRows is \a Dynamic, and the same for the number of columns.
350
  *
350
  *
Lines 390-396 Link Here
390
390
391
/** \returns a block consisting of the top rows of *this.
391
/** \returns a block consisting of the top rows of *this.
392
  *
392
  *
393
  * \tparam N the number of rows in the block
393
  * \tparam N the number of rows in the block as specified at compile-time
394
  * \param n the number of rows in the block as specified at run-time
395
  *
396
  * The compile-time and run-time information should not contradict. In other words,
397
  * \a n should equal \a N unless \a N is \a Dynamic.
394
  *
398
  *
395
  * Example: \include MatrixBase_template_int_topRows.cpp
399
  * Example: \include MatrixBase_template_int_topRows.cpp
396
  * Output: \verbinclude MatrixBase_template_int_topRows.out
400
  * Output: \verbinclude MatrixBase_template_int_topRows.out
Lines 398-413 Link Here
398
  * \sa class Block, block(Index,Index,Index,Index)
402
  * \sa class Block, block(Index,Index,Index,Index)
399
  */
403
  */
400
template<int N>
404
template<int N>
401
inline typename NRowsBlockXpr<N>::Type topRows()
405
inline typename NRowsBlockXpr<N>::Type topRows(Index n = N)
402
{
406
{
403
  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols());
407
  return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
404
}
408
}
405
409
406
/** This is the const version of topRows<int>().*/
410
/** This is the const version of topRows<int>().*/
407
template<int N>
411
template<int N>
408
inline typename ConstNRowsBlockXpr<N>::Type topRows() const
412
inline typename ConstNRowsBlockXpr<N>::Type topRows(Index n = N) const
409
{
413
{
410
  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols());
414
  return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, n, cols());
411
}
415
}
412
416
413
417
Lines 434-440 Link Here
434
438
435
/** \returns a block consisting of the bottom rows of *this.
439
/** \returns a block consisting of the bottom rows of *this.
436
  *
440
  *
437
  * \tparam N the number of rows in the block
441
  * \tparam N the number of rows in the block as specified at compile-time
442
  * \param n the number of rows in the block as specified at run-time
443
  *
444
  * The compile-time and run-time information should not contradict. In other words,
445
  * \a n should equal \a N unless \a N is \a Dynamic.
438
  *
446
  *
439
  * Example: \include MatrixBase_template_int_bottomRows.cpp
447
  * Example: \include MatrixBase_template_int_bottomRows.cpp
440
  * Output: \verbinclude MatrixBase_template_int_bottomRows.out
448
  * Output: \verbinclude MatrixBase_template_int_bottomRows.out
Lines 442-457 Link Here
442
  * \sa class Block, block(Index,Index,Index,Index)
450
  * \sa class Block, block(Index,Index,Index,Index)
443
  */
451
  */
444
template<int N>
452
template<int N>
445
inline typename NRowsBlockXpr<N>::Type bottomRows()
453
inline typename NRowsBlockXpr<N>::Type bottomRows(Index n = N)
446
{
454
{
447
  return typename NRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols());
455
  return typename NRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
448
}
456
}
449
457
450
/** This is the const version of bottomRows<int>().*/
458
/** This is the const version of bottomRows<int>().*/
451
template<int N>
459
template<int N>
452
inline typename ConstNRowsBlockXpr<N>::Type bottomRows() const
460
inline typename ConstNRowsBlockXpr<N>::Type bottomRows(Index n = N) const
453
{
461
{
454
  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols());
462
  return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - n, 0, n, cols());
455
}
463
}
456
464
457
465
Lines 459-486 Link Here
459
/** \returns a block consisting of a range of rows of *this.
467
/** \returns a block consisting of a range of rows of *this.
460
  *
468
  *
461
  * \param startRow the index of the first row in the block
469
  * \param startRow the index of the first row in the block
462
  * \param numRows the number of rows in the block
470
  * \param n the number of rows in the block
463
  *
471
  *
464
  * Example: \include DenseBase_middleRows_int.cpp
472
  * Example: \include DenseBase_middleRows_int.cpp
465
  * Output: \verbinclude DenseBase_middleRows_int.out
473
  * Output: \verbinclude DenseBase_middleRows_int.out
466
  *
474
  *
467
  * \sa class Block, block(Index,Index,Index,Index)
475
  * \sa class Block, block(Index,Index,Index,Index)
468
  */
476
  */
469
inline RowsBlockXpr middleRows(Index startRow, Index numRows)
477
inline RowsBlockXpr middleRows(Index startRow, Index n)
470
{
478
{
471
  return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
479
  return RowsBlockXpr(derived(), startRow, 0, n, cols());
472
}
480
}
473
481
474
/** This is the const version of middleRows(Index,Index).*/
482
/** This is the const version of middleRows(Index,Index).*/
475
inline ConstRowsBlockXpr middleRows(Index startRow, Index numRows) const
483
inline ConstRowsBlockXpr middleRows(Index startRow, Index n) const
476
{
484
{
477
  return ConstRowsBlockXpr(derived(), startRow, 0, numRows, cols());
485
  return ConstRowsBlockXpr(derived(), startRow, 0, n, cols());
478
}
486
}
479
487
480
/** \returns a block consisting of a range of rows of *this.
488
/** \returns a block consisting of a range of rows of *this.
481
  *
489
  *
482
  * \tparam N the number of rows in the block
490
  * \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
491
  * \param startRow the index of the first row in the block
492
  * \param n the number of rows in the block as specified at run-time
493
  *
494
  * The compile-time and run-time information should not contradict. In other words,
495
  * \a n should equal \a N unless \a N is \a Dynamic.
484
  *
496
  *
485
  * Example: \include DenseBase_template_int_middleRows.cpp
497
  * Example: \include DenseBase_template_int_middleRows.cpp
486
  * Output: \verbinclude DenseBase_template_int_middleRows.out
498
  * Output: \verbinclude DenseBase_template_int_middleRows.out
Lines 488-503 Link Here
488
  * \sa class Block, block(Index,Index,Index,Index)
500
  * \sa class Block, block(Index,Index,Index,Index)
489
  */
501
  */
490
template<int N>
502
template<int N>
491
inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow)
503
inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N)
492
{
504
{
493
  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
505
  return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
494
}
506
}
495
507
496
/** This is the const version of middleRows<int>().*/
508
/** This is the const version of middleRows<int>().*/
497
template<int N>
509
template<int N>
498
inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow) const
510
inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow, Index n = N) const
499
{
511
{
500
  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
512
  return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, n, cols());
501
}
513
}
502
514
503
515
Lines 524-530 Link Here
524
536
525
/** \returns a block consisting of the left columns of *this.
537
/** \returns a block consisting of the left columns of *this.
526
  *
538
  *
527
  * \tparam N the number of columns in the block
539
  * \tparam N the number of columns in the block as specified at compile-time
540
  * \param n the number of columns in the block as specified at run-time
541
  *
542
  * The compile-time and run-time information should not contradict. In other words,
543
  * \a n should equal \a N unless \a N is \a Dynamic.
528
  *
544
  *
529
  * Example: \include MatrixBase_template_int_leftCols.cpp
545
  * Example: \include MatrixBase_template_int_leftCols.cpp
530
  * Output: \verbinclude MatrixBase_template_int_leftCols.out
546
  * Output: \verbinclude MatrixBase_template_int_leftCols.out
Lines 532-547 Link Here
532
  * \sa class Block, block(Index,Index,Index,Index)
548
  * \sa class Block, block(Index,Index,Index,Index)
533
  */
549
  */
534
template<int N>
550
template<int N>
535
inline typename NColsBlockXpr<N>::Type leftCols()
551
inline typename NColsBlockXpr<N>::Type leftCols(Index n = N)
536
{
552
{
537
  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N);
553
  return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
538
}
554
}
539
555
540
/** This is the const version of leftCols<int>().*/
556
/** This is the const version of leftCols<int>().*/
541
template<int N>
557
template<int N>
542
inline typename ConstNColsBlockXpr<N>::Type leftCols() const
558
inline typename ConstNColsBlockXpr<N>::Type leftCols(Index n = N) const
543
{
559
{
544
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N);
560
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), n);
545
}
561
}
546
562
547
563
Lines 568-574 Link Here
568
584
569
/** \returns a block consisting of the right columns of *this.
585
/** \returns a block consisting of the right columns of *this.
570
  *
586
  *
571
  * \tparam N the number of columns in the block
587
  * \tparam N the number of columns in the block as specified at compile-time
588
  * \param n the number of columns in the block as specified at run-time
589
  *
590
  * The compile-time and run-time information should not contradict. In other words,
591
  * \a n should equal \a N unless \a N is \a Dynamic.
572
  *
592
  *
573
  * Example: \include MatrixBase_template_int_rightCols.cpp
593
  * Example: \include MatrixBase_template_int_rightCols.cpp
574
  * Output: \verbinclude MatrixBase_template_int_rightCols.out
594
  * Output: \verbinclude MatrixBase_template_int_rightCols.out
Lines 576-591 Link Here
576
  * \sa class Block, block(Index,Index,Index,Index)
596
  * \sa class Block, block(Index,Index,Index,Index)
577
  */
597
  */
578
template<int N>
598
template<int N>
579
inline typename NColsBlockXpr<N>::Type rightCols()
599
inline typename NColsBlockXpr<N>::Type rightCols(Index n = N)
580
{
600
{
581
  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
601
  return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
582
}
602
}
583
603
584
/** This is the const version of rightCols<int>().*/
604
/** This is the const version of rightCols<int>().*/
585
template<int N>
605
template<int N>
586
inline typename ConstNColsBlockXpr<N>::Type rightCols() const
606
inline typename ConstNColsBlockXpr<N>::Type rightCols(Index n = N) const
587
{
607
{
588
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
608
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - n, rows(), n);
589
}
609
}
590
610
591
611
Lines 613-620 Link Here
613
633
614
/** \returns a block consisting of a range of columns of *this.
634
/** \returns a block consisting of a range of columns of *this.
615
  *
635
  *
616
  * \tparam N the number of columns in the block
636
  * \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
637
  * \param startCol the index of the first column in the block
638
  * \param n the number of columns in the block as specified at run-time
639
  *
640
  * The compile-time and run-time information should not contradict. In other words,
641
  * \a n should equal \a N unless \a N is \a Dynamic.
618
  *
642
  *
619
  * Example: \include DenseBase_template_int_middleCols.cpp
643
  * Example: \include DenseBase_template_int_middleCols.cpp
620
  * Output: \verbinclude DenseBase_template_int_middleCols.out
644
  * Output: \verbinclude DenseBase_template_int_middleCols.out
Lines 622-637 Link Here
622
  * \sa class Block, block(Index,Index,Index,Index)
646
  * \sa class Block, block(Index,Index,Index,Index)
623
  */
647
  */
624
template<int N>
648
template<int N>
625
inline typename NColsBlockXpr<N>::Type middleCols(Index startCol)
649
inline typename NColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N)
626
{
650
{
627
  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
651
  return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
628
}
652
}
629
653
630
/** This is the const version of middleCols<int>().*/
654
/** This is the const version of middleCols<int>().*/
631
template<int N>
655
template<int N>
632
inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol) const
656
inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol, Index n = N) const
633
{
657
{
634
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
658
  return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), n);
635
}
659
}
636
660
637
661
Lines 667-681 Link Here
667
691
668
/** \returns an expression of a block in *this.
692
/** \returns an expression of a block in *this.
669
  *
693
  *
670
  * \tparam BlockRows number of rows in block as specified at compile time
694
  * \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
695
  * \tparam BlockCols number of columns in block as specified at compile-time
672
  * \param  startRow  the first row in the block
696
  * \param  startRow  the first row in the block
673
  * \param  startCol  the first column in the block
697
  * \param  startCol  the first column in the block
674
  * \param  blockRows number of rows in block as specified at run time
698
  * \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
699
  * \param  blockCols number of columns in block as specified at run-time
676
  *
700
  *
677
  * This function is mainly useful for blocks where the number of rows is specified at compile time
701
  * 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
702
  * 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
703
  * 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.
704
  * \a BlockRows is \a Dynamic, and the same for the number of columns.
681
  *
705
  *
Lines 738-744 Link Here
738
  * \only_for_vectors
762
  * \only_for_vectors
739
  *
763
  *
740
  * \param start the first coefficient in the segment
764
  * \param start the first coefficient in the segment
741
  * \param vecSize the number of coefficients in the segment
765
  * \param n the number of coefficients in the segment
742
  *
766
  *
743
  * Example: \include MatrixBase_segment_int_int.cpp
767
  * Example: \include MatrixBase_segment_int_int.cpp
744
  * Output: \verbinclude MatrixBase_segment_int_int.out
768
  * Output: \verbinclude MatrixBase_segment_int_int.out
Lines 749-773 Link Here
749
  *
773
  *
750
  * \sa class Block, segment(Index)
774
  * \sa class Block, segment(Index)
751
  */
775
  */
752
inline SegmentReturnType segment(Index start, Index vecSize)
776
inline SegmentReturnType segment(Index start, Index n)
753
{
777
{
754
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
778
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
755
  return SegmentReturnType(derived(), start, vecSize);
779
  return SegmentReturnType(derived(), start, n);
756
}
780
}
757
781
758
782
759
/** This is the const version of segment(Index,Index).*/
783
/** This is the const version of segment(Index,Index).*/
760
inline ConstSegmentReturnType segment(Index start, Index vecSize) const
784
inline ConstSegmentReturnType segment(Index start, Index n) const
761
{
785
{
762
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
786
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
763
  return ConstSegmentReturnType(derived(), start, vecSize);
787
  return ConstSegmentReturnType(derived(), start, n);
764
}
788
}
765
789
766
/** \returns a dynamic-size expression of the first coefficients of *this.
790
/** \returns a dynamic-size expression of the first coefficients of *this.
767
  *
791
  *
768
  * \only_for_vectors
792
  * \only_for_vectors
769
  *
793
  *
770
  * \param vecSize the number of coefficients in the block
794
  * \param n the number of coefficients in the segment
771
  *
795
  *
772
  * Example: \include MatrixBase_start_int.cpp
796
  * Example: \include MatrixBase_start_int.cpp
773
  * Output: \verbinclude MatrixBase_start_int.out
797
  * Output: \verbinclude MatrixBase_start_int.out
Lines 778-802 Link Here
778
  *
802
  *
779
  * \sa class Block, block(Index,Index)
803
  * \sa class Block, block(Index,Index)
780
  */
804
  */
781
inline SegmentReturnType head(Index vecSize)
805
inline SegmentReturnType head(Index n)
782
{
806
{
783
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
807
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
784
  return SegmentReturnType(derived(), 0, vecSize);
808
  return SegmentReturnType(derived(), 0, n);
785
}
809
}
786
810
787
/** This is the const version of head(Index).*/
811
/** This is the const version of head(Index).*/
788
inline ConstSegmentReturnType
812
inline ConstSegmentReturnType head(Index n) const
789
  head(Index vecSize) const
790
{
813
{
791
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
814
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
792
  return ConstSegmentReturnType(derived(), 0, vecSize);
815
  return ConstSegmentReturnType(derived(), 0, n);
793
}
816
}
794
817
795
/** \returns a dynamic-size expression of the last coefficients of *this.
818
/** \returns a dynamic-size expression of the last coefficients of *this.
796
  *
819
  *
797
  * \only_for_vectors
820
  * \only_for_vectors
798
  *
821
  *
799
  * \param vecSize the number of coefficients in the block
822
  * \param n the number of coefficients in the segment
800
  *
823
  *
801
  * Example: \include MatrixBase_end_int.cpp
824
  * Example: \include MatrixBase_end_int.cpp
802
  * Output: \verbinclude MatrixBase_end_int.out
825
  * Output: \verbinclude MatrixBase_end_int.out
Lines 807-901 Link Here
807
  *
830
  *
808
  * \sa class Block, block(Index,Index)
831
  * \sa class Block, block(Index,Index)
809
  */
832
  */
810
inline SegmentReturnType tail(Index vecSize)
833
inline SegmentReturnType tail(Index n)
811
{
834
{
812
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
835
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
813
  return SegmentReturnType(derived(), this->size() - vecSize, vecSize);
836
  return SegmentReturnType(derived(), this->size() - n, n);
814
}
837
}
815
838
816
/** This is the const version of tail(Index).*/
839
/** This is the const version of tail(Index).*/
817
inline ConstSegmentReturnType tail(Index vecSize) const
840
inline ConstSegmentReturnType tail(Index n) const
818
{
841
{
819
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
842
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
820
  return ConstSegmentReturnType(derived(), this->size() - vecSize, vecSize);
843
  return ConstSegmentReturnType(derived(), this->size() - n, n);
821
}
844
}
822
845
823
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
846
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
824
  *
847
  *
825
  * \only_for_vectors
848
  * \only_for_vectors
826
  *
849
  *
827
  * The template parameter \a Size is the number of coefficients in the block
850
  * \tparam N the number of coefficients in the segment as specified at compile-time
851
  * \param start the index of the first element in the segment
852
  * \param n the number of coefficients in the segment as specified at compile-time
828
  *
853
  *
829
  * \param start the index of the first element of the sub-vector
854
  * The compile-time and run-time information should not contradict. In other words,
855
  * \a n should equal \a N unless \a N is \a Dynamic.
830
  *
856
  *
831
  * Example: \include MatrixBase_template_int_segment.cpp
857
  * Example: \include MatrixBase_template_int_segment.cpp
832
  * Output: \verbinclude MatrixBase_template_int_segment.out
858
  * Output: \verbinclude MatrixBase_template_int_segment.out
833
  *
859
  *
834
  * \sa class Block
860
  * \sa class Block
835
  */
861
  */
836
template<int Size>
862
template<int N>
837
inline typename FixedSegmentReturnType<Size>::Type segment(Index start)
863
inline typename FixedSegmentReturnType<N>::Type segment(Index start, Index n = N)
838
{
864
{
839
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
865
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
840
  return typename FixedSegmentReturnType<Size>::Type(derived(), start);
866
  return typename FixedSegmentReturnType<N>::Type(derived(), start, n);
841
}
867
}
842
868
843
/** This is the const version of segment<int>(Index).*/
869
/** This is the const version of segment<int>(Index).*/
844
template<int Size>
870
template<int N>
845
inline typename ConstFixedSegmentReturnType<Size>::Type segment(Index start) const
871
inline typename ConstFixedSegmentReturnType<N>::Type segment(Index start, Index n = N) const
846
{
872
{
847
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
873
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
848
  return typename ConstFixedSegmentReturnType<Size>::Type(derived(), start);
874
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), start, n);
849
}
875
}
850
876
851
/** \returns a fixed-size expression of the first coefficients of *this.
877
/** \returns a fixed-size expression of the first coefficients of *this.
852
  *
878
  *
853
  * \only_for_vectors
879
  * \only_for_vectors
854
  *
880
  *
855
  * The template parameter \a Size is the number of coefficients in the block
881
  * \tparam N the number of coefficients in the segment as specified at compile-time
882
  * \param  n the number of coefficients in the segment as specified at run-time
883
  *
884
  * The compile-time and run-time information should not contradict. In other words,
885
  * \a n should equal \a N unless \a N is \a Dynamic.
856
  *
886
  *
857
  * Example: \include MatrixBase_template_int_start.cpp
887
  * Example: \include MatrixBase_template_int_start.cpp
858
  * Output: \verbinclude MatrixBase_template_int_start.out
888
  * Output: \verbinclude MatrixBase_template_int_start.out
859
  *
889
  *
860
  * \sa class Block
890
  * \sa class Block
861
  */
891
  */
862
template<int Size>
892
template<int N>
863
inline typename FixedSegmentReturnType<Size>::Type head()
893
inline typename FixedSegmentReturnType<N>::Type head(Index n = N)
864
{
894
{
865
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
895
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
866
  return typename FixedSegmentReturnType<Size>::Type(derived(), 0);
896
  return typename FixedSegmentReturnType<N>::Type(derived(), 0, n);
867
}
897
}
868
898
869
/** This is the const version of head<int>().*/
899
/** This is the const version of head<int>().*/
870
template<int Size>
900
template<int N>
871
inline typename ConstFixedSegmentReturnType<Size>::Type head() const
901
inline typename ConstFixedSegmentReturnType<N>::Type head(Index n = N) const
872
{
902
{
873
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
903
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
874
  return typename ConstFixedSegmentReturnType<Size>::Type(derived(), 0);
904
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), 0, n);
875
}
905
}
876
906
877
/** \returns a fixed-size expression of the last coefficients of *this.
907
/** \returns a fixed-size expression of the last coefficients of *this.
878
  *
908
  *
879
  * \only_for_vectors
909
  * \only_for_vectors
880
  *
910
  *
881
  * The template parameter \a Size is the number of coefficients in the block
911
  * \tparam N the number of coefficients in the segment as specified at compile-time
912
  * \param  n the number of coefficients in the segment as specified at run-time
913
  *
914
  * The compile-time and run-time information should not contradict. In other words,
915
  * \a n should equal \a N unless \a N is \a Dynamic.
882
  *
916
  *
883
  * Example: \include MatrixBase_template_int_end.cpp
917
  * Example: \include MatrixBase_template_int_end.cpp
884
  * Output: \verbinclude MatrixBase_template_int_end.out
918
  * Output: \verbinclude MatrixBase_template_int_end.out
885
  *
919
  *
886
  * \sa class Block
920
  * \sa class Block
887
  */
921
  */
888
template<int Size>
922
template<int N>
889
inline typename FixedSegmentReturnType<Size>::Type tail()
923
inline typename FixedSegmentReturnType<N>::Type tail(Index n = N)
890
{
924
{
891
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
925
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
892
  return typename FixedSegmentReturnType<Size>::Type(derived(), size() - Size);
926
  return typename FixedSegmentReturnType<N>::Type(derived(), size() - n);
893
}
927
}
894
928
895
/** This is the const version of tail<int>.*/
929
/** This is the const version of tail<int>.*/
896
template<int Size>
930
template<int N>
897
inline typename ConstFixedSegmentReturnType<Size>::Type tail() const
931
inline typename ConstFixedSegmentReturnType<N>::Type tail(Index n = N) const
898
{
932
{
899
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
933
  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
900
  return typename ConstFixedSegmentReturnType<Size>::Type(derived(), size() - Size);
934
  return typename ConstFixedSegmentReturnType<N>::Type(derived(), size() - n);
901
}
935
}

Return to bug 579