| Re: [eigen] Feature suggestion: interior row and column ranges [patch attached] |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Hi all,
Attachments:
1. patch with {row,col}Range() renamed to middle{Rows,Cols}() and updated
test-case file
2. Example files referred to in the Doxygen documentation
3. Corresponding sample output files
Notes:
The Doxygen comments in Block.h refer to MatrixBase_*.cpp as the example
files. I think these should be renamed to DenseBase_*.cpp. So far I have
followed the existing nomenclature in my patch. I am guessing that at the
right time one of the maintainers will run a script to make this correction.
thanks,
Manoj
On Tuesday 29 June 2010 01:39:57 pm Gael Guennebaud wrote:
> you can export a range of commit this way:
>
> hg export rev_start:rev_end,
>
> e.g.:
>
> hg export 3090:tip
>
> gael
>
> On Tue, Jun 29, 2010 at 6:50 PM, Manoj Rajagopalan <rmanoj@xxxxxxxxx> wrote:
> > I made the changes and performed a local commit without rollback on the
> > previous local commit. Now the hg export tip > diff-file stores only the
> > diff with respect to the last local commit and not with respect to the
> > file-versions in the hg repo.
> >
> > How do I fix this problem? I performed one rollback (after making a copy
> > of the latest file with all desirable changes) and I got back the file
> > with rowRange() instead of middleRows(). Now I need to replace this with
> > the file in the repo. "hg revert DenseBase.h" doesn't seem to have any
> > effect.
> >
> > thanks,
> > Manoj
> >
> > On Sunday 27 June 2010 12:25:31 pm Benoit Jacob wrote:
> >> 2010/6/27 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> >> > 2010/6/27 Manoj Rajagopalan <rmanoj@xxxxxxxxx>:
> >> >> Do you want me to resend the patch with the new names - middleRows()
> >> >> and middleCols()?
> >> >
> >> > Yes please and also make sure to indent with spaces, not tabs, in
> >> > DenseBase.h
> >>
> >> Also please update test/corners.cpp to test all your new functions.
> >> And yes, that filename becomes not so good anymore, but let's take
> >> care of that later.
> >>
> >> Benoit
> >>
> >> > Benoit
> >> >
> >> >> Thanks,
> >> >> Manoj
# HG changeset patch
# User Manoj Rajagopalan <rmanoj@xxxxxxxxx>
# Date 1277588237 14400
# Node ID 005e59ee039e8edbf6056361b057022fbdacb40a
# Parent 687dca0e53d43b123e64e8640a08827de3fa0429
Included definitions for rowRange() and colRange() member functions of DenseBase
diff -r 687dca0e53d4 -r 005e59ee039e Eigen/src/Core/Block.h
--- a/Eigen/src/Core/Block.h Sat Jun 26 23:15:06 2010 +0200
+++ b/Eigen/src/Core/Block.h Sat Jun 26 17:37:17 2010 -0400
@@ -678,9 +678,62 @@ DenseBase<Derived>::bottomRows() const
+/** \returns a block consisting of a range of rows of *this.
+ *
+ * \param startRow the index of the first row in the block
+ * \param numRows the number of rows in the block
+ *
+ * Example: \include MatrixBase_rowRange_int.cpp
+ * Output: \verbinclude MatrixBase_rowRange_int.out
+ *
+ * \sa class Block, block(Index,Index,Index,Index)
+ */
+template<typename Derived>
+inline typename DenseBase<Derived>::RowsBlockXpr DenseBase<Derived>
+ ::rowRange(Index startRow, Index numRows)
+{
+ return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
+}
+/** This is the const version of rowRange(Index,Index).*/
+template<typename Derived>
+inline const typename DenseBase<Derived>::RowsBlockXpr
+DenseBase<Derived>::rowRange(Index startRow, Index numRows) const
+{
+ return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
+}
-/** \returns a block consisting of the top columns of *this.
+/** \returns a block consisting of a range of rows of *this.
+ *
+ * \param N the number of rows in the block
+ * \param startRow the index of the first row in the block
+ *
+ * Example: \include MatrixBase_template_int_rowRange.cpp
+ * Output: \verbinclude MatrixBase_template_int_rowRange.out
+ *
+ * \sa class Block, block(Index,Index,Index,Index)
+ */
+template<typename Derived>
+template<int N>
+inline typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type
+DenseBase<Derived>::rowRange(Index startRow)
+{
+ return typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
+}
+
+/** This is the const version of rowRange<int>().*/
+template<typename Derived>
+template<int N>
+inline const typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type
+DenseBase<Derived>::rowRange(Index startRow) const
+{
+ return typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
+}
+
+
+
+
+/** \returns a block consisting of the left columns of *this.
*
* \param n the number of columns in the block
*
@@ -782,6 +835,61 @@ DenseBase<Derived>::rightCols() const
DenseBase<Derived>::rightCols() const
{
return typename DenseBase<Derived>::template NColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
+}
+
+
+
+
+/** \returns a block consisting of a range of columns of *this.
+ *
+ * \param startCol the index of the first column in the block
+ * \param numCols the number of columns in the block
+ *
+ * Example: \include MatrixBase_colRange_int.cpp
+ * Output: \verbinclude MatrixBase_colRange_int.out
+ *
+ * \sa class Block, block(Index,Index,Index,Index)
+ */
+template<typename Derived>
+inline typename DenseBase<Derived>::ColsBlockXpr DenseBase<Derived>
+ ::colRange(Index startCol, Index numCols)
+{
+ return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
+}
+
+/** This is the const version of colRange(Index,Index).*/
+template<typename Derived>
+inline const typename DenseBase<Derived>::ColsBlockXpr
+DenseBase<Derived>::colRange(Index startCol, Index numCols) const
+{
+ return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
+}
+
+/** \returns a block consisting of a range of columns of *this.
+ *
+ * \param N the number of columns in the block
+ * \param startCol the index of the first column in the block
+ *
+ * Example: \include MatrixBase_template_int_colRange.cpp
+ * Output: \verbinclude MatrixBase_template_int_colRange.out
+ *
+ * \sa class Block, block(Index,Index,Index,Index)
+ */
+template<typename Derived>
+template<int N>
+inline typename DenseBase<Derived>::template NColsBlockXpr<N>::Type
+DenseBase<Derived>::colRange(Index startCol)
+{
+ return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
+}
+
+/** This is the const version of colRange<int>().*/
+template<typename Derived>
+template<int N>
+inline const typename DenseBase<Derived>::template NColsBlockXpr<N>::Type
+DenseBase<Derived>::colRange(Index startCol) const
+{
+ return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
}
diff -r 687dca0e53d4 -r 005e59ee039e Eigen/src/Core/DenseBase.h
--- a/Eigen/src/Core/DenseBase.h Sat Jun 26 23:15:06 2010 +0200
+++ b/Eigen/src/Core/DenseBase.h Sat Jun 26 17:37:17 2010 -0400
@@ -326,10 +326,14 @@ template<typename Derived> class DenseBa
const RowsBlockXpr topRows(Index n) const;
RowsBlockXpr bottomRows(Index n);
const RowsBlockXpr bottomRows(Index n) const;
+ RowsBlockXpr rowRange(Index startRow, Index numRows);
+ const RowsBlockXpr rowRange(Index startRow, Index numRows) const;
ColsBlockXpr leftCols(Index n);
const ColsBlockXpr leftCols(Index n) const;
ColsBlockXpr rightCols(Index n);
const ColsBlockXpr rightCols(Index n) const;
+ ColsBlockXpr colRange(Index startCol, Index numCols);
+ const ColsBlockXpr colRange(Index startCol, Index numCols) const;
template<int CRows, int CCols> Block<Derived, CRows, CCols> topLeftCorner();
template<int CRows, int CCols> const Block<Derived, CRows, CCols> topLeftCorner() const;
@@ -344,10 +348,14 @@ template<typename Derived> class DenseBa
template<int NRows> const typename NRowsBlockXpr<NRows>::Type topRows() const;
template<int NRows> typename NRowsBlockXpr<NRows>::Type bottomRows();
template<int NRows> const typename NRowsBlockXpr<NRows>::Type bottomRows() const;
+ template<int NRows> typename NRowsBlockXpr<NRows>::Type rowRange(Index startRow);
+ template<int NRows> const typename NRowsBlockXpr<NRows>::Type rowRange(Index startRow) const;
template<int NCols> typename NColsBlockXpr<NCols>::Type leftCols();
template<int NCols> const typename NColsBlockXpr<NCols>::Type leftCols() const;
template<int NCols> typename NColsBlockXpr<NCols>::Type rightCols();
template<int NCols> const typename NColsBlockXpr<NCols>::Type rightCols() const;
+ template<int NCols> typename NColsBlockXpr<NCols>::Type colRange(Index startCol);
+ template<int NCols> const typename NColsBlockXpr<NCols>::Type colRange(Index startCol) const;
template<int BlockRows, int BlockCols>
Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol);
# HG changeset patch
# User Manoj Rajagopalan <rmanoj@xxxxxxxxx>
# Date 1277829598 14400
# Node ID 80184194ba92f590884da878fabb2487b376575f
# Parent 005e59ee039e8edbf6056361b057022fbdacb40a
Included tests for middleRows() and middleCols()
diff -r 005e59ee039e -r 80184194ba92 test/corners.cpp
--- a/test/corners.cpp Sat Jun 26 17:37:17 2010 -0400
+++ b/test/corners.cpp Tue Jun 29 12:39:58 2010 -0400
@@ -45,13 +45,20 @@ template<typename MatrixType> void corne
COMPARE_CORNER(bottomLeftCorner(r,c), block(rows-r,0,r,c));
COMPARE_CORNER(bottomRightCorner(r,c), block(rows-r,cols-c,r,c));
+ Index sr = ei_random<Index>(1,rows) - 1;
+ Index nr = ei_random<Index>(1,rows-sr);
+ Index sc = ei_random<Index>(1,cols) - 1;
+ Index nc = ei_random<Index>(1,cols-sc);
+
COMPARE_CORNER(topRows(r), block(0,0,r,cols));
+ COMPARE_CORNER(middleRows(sr,nr), block(sr,0,nr,cols));
COMPARE_CORNER(bottomRows(r), block(rows-r,0,r,cols));
COMPARE_CORNER(leftCols(c), block(0,0,rows,c));
+ COMPARE_CORNER(middleCols(sc,nc), block(0,sc,rows,nc));
COMPARE_CORNER(rightCols(c), block(0,cols-c,rows,c));
}
-template<typename MatrixType, int CRows, int CCols> void corners_fixedsize()
+template<typename MatrixType, int CRows, int CCols, int SRows, int SCols> void corners_fixedsize()
{
MatrixType matrix = MatrixType::Random();
const MatrixType const_matrix = MatrixType::Random();
@@ -60,7 +67,9 @@ template<typename MatrixType, int CRows,
rows = MatrixType::RowsAtCompileTime,
cols = MatrixType::ColsAtCompileTime,
r = CRows,
- c = CCols
+ c = CCols,
+ sr = SRows,
+ sc = SCols
};
VERIFY_IS_EQUAL((matrix.template topLeftCorner<r,c>()), (matrix.template block<r,c>(0,0)));
@@ -69,8 +78,10 @@ template<typename MatrixType, int CRows,
VERIFY_IS_EQUAL((matrix.template bottomRightCorner<r,c>()), (matrix.template block<r,c>(rows-r,cols-c)));
VERIFY_IS_EQUAL((matrix.template topRows<r>()), (matrix.template block<r,cols>(0,0)));
+ VERIFY_IS_EQUAL((matrix.template middleRows<r>(sr)), (matrix.template block<r,cols>(sr,0)));
VERIFY_IS_EQUAL((matrix.template bottomRows<r>()), (matrix.template block<r,cols>(rows-r,0)));
VERIFY_IS_EQUAL((matrix.template leftCols<c>()), (matrix.template block<rows,c>(0,0)));
+ VERIFY_IS_EQUAL((matrix.template middleCols<c>(sc)), (matrix.template block<rows,c>(0,sc)));
VERIFY_IS_EQUAL((matrix.template rightCols<c>()), (matrix.template block<rows,c>(0,cols-c)));
VERIFY_IS_EQUAL((const_matrix.template topLeftCorner<r,c>()), (const_matrix.template block<r,c>(0,0)));
@@ -79,8 +90,10 @@ template<typename MatrixType, int CRows,
VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner<r,c>()), (const_matrix.template block<r,c>(rows-r,cols-c)));
VERIFY_IS_EQUAL((const_matrix.template topRows<r>()), (const_matrix.template block<r,cols>(0,0)));
+ VERIFY_IS_EQUAL((const_matrix.template middleRows<r>(sr)), (const_matrix.template block<r,cols>(sr,0)));
VERIFY_IS_EQUAL((const_matrix.template bottomRows<r>()), (const_matrix.template block<r,cols>(rows-r,0)));
VERIFY_IS_EQUAL((const_matrix.template leftCols<c>()), (const_matrix.template block<rows,c>(0,0)));
+ VERIFY_IS_EQUAL((const_matrix.template middleCols<c>(sc)), (const_matrix.template block<rows,c>(0,sc)));
VERIFY_IS_EQUAL((const_matrix.template rightCols<c>()), (const_matrix.template block<rows,c>(0,cols-c)));
}
@@ -93,8 +106,8 @@ void test_corners()
CALL_SUBTEST_4( corners(MatrixXcf(5, 7)) );
CALL_SUBTEST_5( corners(MatrixXf(21, 20)) );
- CALL_SUBTEST_1(( corners_fixedsize<Matrix<float, 1, 1>, 1, 1>() ));
- CALL_SUBTEST_2(( corners_fixedsize<Matrix4d,2,2>() ));
- CALL_SUBTEST_3(( corners_fixedsize<Matrix<int,10,12>,4,7>() ));
+ CALL_SUBTEST_1(( corners_fixedsize<Matrix<float, 1, 1>, 1, 1, 0, 0>() ));
+ CALL_SUBTEST_2(( corners_fixedsize<Matrix4d,2,2,1,1>() ));
+ CALL_SUBTEST_3(( corners_fixedsize<Matrix<int,10,12>,4,7,5,2>() ));
}
}
# HG changeset patch
# User Manoj Rajagopalan <rmanoj@xxxxxxxxx>
# Date 1277836299 14400
# Node ID a8d1f57c46bc5ce62a4536d118efe5b1f88e9436
# Parent 80184194ba92f590884da878fabb2487b376575f
Renamed DenseBase::{row,col}Range() to DenseBase::middle{Rows,Cols}()
diff -r 80184194ba92 -r a8d1f57c46bc Eigen/src/Core/Block.h
--- a/Eigen/src/Core/Block.h Tue Jun 29 12:39:58 2010 -0400
+++ b/Eigen/src/Core/Block.h Tue Jun 29 14:31:39 2010 -0400
@@ -683,22 +683,22 @@ DenseBase<Derived>::bottomRows() const
* \param startRow the index of the first row in the block
* \param numRows the number of rows in the block
*
- * Example: \include MatrixBase_rowRange_int.cpp
- * Output: \verbinclude MatrixBase_rowRange_int.out
+ * Example: \include MatrixBase_middleRows_int.cpp
+ * Output: \verbinclude MatrixBase_middleRows_int.out
*
* \sa class Block, block(Index,Index,Index,Index)
*/
template<typename Derived>
inline typename DenseBase<Derived>::RowsBlockXpr DenseBase<Derived>
- ::rowRange(Index startRow, Index numRows)
+ ::middleRows(Index startRow, Index numRows)
{
return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
}
-/** This is the const version of rowRange(Index,Index).*/
+/** This is the const version of middleRows(Index,Index).*/
template<typename Derived>
inline const typename DenseBase<Derived>::RowsBlockXpr
-DenseBase<Derived>::rowRange(Index startRow, Index numRows) const
+DenseBase<Derived>::middleRows(Index startRow, Index numRows) const
{
return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
}
@@ -708,24 +708,24 @@ DenseBase<Derived>::rowRange(Index start
* \param N the number of rows in the block
* \param startRow the index of the first row in the block
*
- * Example: \include MatrixBase_template_int_rowRange.cpp
- * Output: \verbinclude MatrixBase_template_int_rowRange.out
+ * Example: \include MatrixBase_template_int_middleRows.cpp
+ * Output: \verbinclude MatrixBase_template_int_middleRows.out
*
* \sa class Block, block(Index,Index,Index,Index)
*/
template<typename Derived>
template<int N>
inline typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type
-DenseBase<Derived>::rowRange(Index startRow)
+DenseBase<Derived>::middleRows(Index startRow)
{
return typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
}
-/** This is the const version of rowRange<int>().*/
+/** This is the const version of middleRows<int>().*/
template<typename Derived>
template<int N>
inline const typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type
-DenseBase<Derived>::rowRange(Index startRow) const
+DenseBase<Derived>::middleRows(Index startRow) const
{
return typename DenseBase<Derived>::template NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
}
@@ -845,22 +845,22 @@ DenseBase<Derived>::rightCols() const
* \param startCol the index of the first column in the block
* \param numCols the number of columns in the block
*
- * Example: \include MatrixBase_colRange_int.cpp
- * Output: \verbinclude MatrixBase_colRange_int.out
+ * Example: \include MatrixBase_middleCols_int.cpp
+ * Output: \verbinclude MatrixBase_middleCols_int.out
*
* \sa class Block, block(Index,Index,Index,Index)
*/
template<typename Derived>
inline typename DenseBase<Derived>::ColsBlockXpr DenseBase<Derived>
- ::colRange(Index startCol, Index numCols)
+ ::middleCols(Index startCol, Index numCols)
{
return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
}
-/** This is the const version of colRange(Index,Index).*/
+/** This is the const version of middleCols(Index,Index).*/
template<typename Derived>
inline const typename DenseBase<Derived>::ColsBlockXpr
-DenseBase<Derived>::colRange(Index startCol, Index numCols) const
+DenseBase<Derived>::middleCols(Index startCol, Index numCols) const
{
return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
}
@@ -870,24 +870,24 @@ DenseBase<Derived>::colRange(Index start
* \param N the number of columns in the block
* \param startCol the index of the first column in the block
*
- * Example: \include MatrixBase_template_int_colRange.cpp
- * Output: \verbinclude MatrixBase_template_int_colRange.out
+ * Example: \include MatrixBase_template_int_middleCols.cpp
+ * Output: \verbinclude MatrixBase_template_int_middleCols.out
*
* \sa class Block, block(Index,Index,Index,Index)
*/
template<typename Derived>
template<int N>
inline typename DenseBase<Derived>::template NColsBlockXpr<N>::Type
-DenseBase<Derived>::colRange(Index startCol)
+DenseBase<Derived>::middleCols(Index startCol)
{
return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
}
-/** This is the const version of colRange<int>().*/
+/** This is the const version of middleCols<int>().*/
template<typename Derived>
template<int N>
inline const typename DenseBase<Derived>::template NColsBlockXpr<N>::Type
-DenseBase<Derived>::colRange(Index startCol) const
+DenseBase<Derived>::middleCols(Index startCol) const
{
return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
}
diff -r 80184194ba92 -r a8d1f57c46bc Eigen/src/Core/DenseBase.h
--- a/Eigen/src/Core/DenseBase.h Tue Jun 29 12:39:58 2010 -0400
+++ b/Eigen/src/Core/DenseBase.h Tue Jun 29 14:31:39 2010 -0400
@@ -326,14 +326,14 @@ template<typename Derived> class DenseBa
const RowsBlockXpr topRows(Index n) const;
RowsBlockXpr bottomRows(Index n);
const RowsBlockXpr bottomRows(Index n) const;
- RowsBlockXpr rowRange(Index startRow, Index numRows);
- const RowsBlockXpr rowRange(Index startRow, Index numRows) const;
+ RowsBlockXpr middleRows(Index startRow, Index numRows);
+ const RowsBlockXpr middleRows(Index startRow, Index numRows) const;
ColsBlockXpr leftCols(Index n);
const ColsBlockXpr leftCols(Index n) const;
ColsBlockXpr rightCols(Index n);
const ColsBlockXpr rightCols(Index n) const;
- ColsBlockXpr colRange(Index startCol, Index numCols);
- const ColsBlockXpr colRange(Index startCol, Index numCols) const;
+ ColsBlockXpr middleCols(Index startCol, Index numCols);
+ const ColsBlockXpr middleCols(Index startCol, Index numCols) const;
template<int CRows, int CCols> Block<Derived, CRows, CCols> topLeftCorner();
template<int CRows, int CCols> const Block<Derived, CRows, CCols> topLeftCorner() const;
@@ -348,14 +348,14 @@ template<typename Derived> class DenseBa
template<int NRows> const typename NRowsBlockXpr<NRows>::Type topRows() const;
template<int NRows> typename NRowsBlockXpr<NRows>::Type bottomRows();
template<int NRows> const typename NRowsBlockXpr<NRows>::Type bottomRows() const;
- template<int NRows> typename NRowsBlockXpr<NRows>::Type rowRange(Index startRow);
- template<int NRows> const typename NRowsBlockXpr<NRows>::Type rowRange(Index startRow) const;
+ template<int NRows> typename NRowsBlockXpr<NRows>::Type middleRows(Index startRow);
+ template<int NRows> const typename NRowsBlockXpr<NRows>::Type middleRows(Index startRow) const;
template<int NCols> typename NColsBlockXpr<NCols>::Type leftCols();
template<int NCols> const typename NColsBlockXpr<NCols>::Type leftCols() const;
template<int NCols> typename NColsBlockXpr<NCols>::Type rightCols();
template<int NCols> const typename NColsBlockXpr<NCols>::Type rightCols() const;
- template<int NCols> typename NColsBlockXpr<NCols>::Type colRange(Index startCol);
- template<int NCols> const typename NColsBlockXpr<NCols>::Type colRange(Index startCol) const;
+ template<int NCols> typename NColsBlockXpr<NCols>::Type middleCols(Index startCol);
+ template<int NCols> const typename NColsBlockXpr<NCols>::Type middleCols(Index startCol) const;
template<int BlockRows, int BlockCols>
Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol);
Attachment:
MatrixBase_middleCols_int.out
Description: chemical/mopac-out
#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
int main(void)
{
int const N = 5;
MatrixXi A(N,N);
A.setRandom();
cout << "A =\n" << A << '\n' << endl;
cout << "A(1..3,:) =\n" << A.middleCols(1,3) << endl;
return 0;
}
#include <eigen-aliases.h>
#include <iostream>
#include "fill_seq.h"
using namespace Eigen;
using namespace eigen_aliases;
using namespace std;
int main(void)
{
int const N = 5;
MatrixXi A(N,N);
A.setRandom();
cout << "A =\n" << A << '\n' << endl;
cout << "A(2..3,:) =\n" << A.middleRows(2,2) << endl;
return 0;
}
#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
int main(void)
{
int const N = 5;
MatrixXi A(N,N);
A.setRandom();
cout << "A =\n" << A << '\n' << endl;
cout << "A(:,1..3) =\n" << A.middleCols<3>(1) << endl;
return 0;
}
Attachment:
MatrixBase_template_int_middleCols.out
Description: chemical/mopac-out
#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
int main(void)
{
int const N = 5;
MatrixXi A(N,N);
A.setRandom();
cout << "A =\n" << A << '\n' << endl;
cout << "A(1..3,:) =\n" << A.middleRows<3>(1) << endl;
return 0;
}
Attachment:
MatrixBase_middleRows_int.out
Description: chemical/mopac-out
Attachment:
MatrixBase_template_int_middleRows.out
Description: chemical/mopac-out
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |