mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-10 02:39:03 +08:00
allow to do xpr = solve(b) etc... just by adding a dummy MatrixBase::resize()
This commit is contained in:
parent
4f9e270343
commit
176c26feb5
@ -189,11 +189,24 @@ template<typename Derived> class MatrixBase
|
||||
/** \returns the size of the inner dimension according to the storage order,
|
||||
* i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
|
||||
int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
|
||||
|
||||
|
||||
/** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
|
||||
* Matrix::resize(). The present method only asserts that the new size equals the old size, and does
|
||||
* nothing else.
|
||||
*/
|
||||
void resize(int size)
|
||||
{ ei_assert(size == this->size() && "MatrixBase::resize() does not actually allow to resize."); }
|
||||
/** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
|
||||
* Matrix::resize(). The present method only asserts that the new size equals the old size, and does
|
||||
* nothing else.
|
||||
*/
|
||||
void resize(int rows, int cols)
|
||||
{ ei_assert(rows == this->rows() && cols == this->cols() && "MatrixBase::resize() does not actually allow to resize."); }
|
||||
|
||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||
/** \internal the plain matrix type corresponding to this expression. Note that is not necessarily
|
||||
* exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const
|
||||
* reference to a matrix, not a matrix! It guaranteed however, that the return type of eval() is either
|
||||
* reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either
|
||||
* PlainMatrixType or const PlainMatrixType&.
|
||||
*/
|
||||
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
|
||||
|
@ -40,7 +40,6 @@ template<typename MatrixType> void lu_non_invertible()
|
||||
typename ei_lu_kernel_impl<MatrixType>::ReturnMatrixType m1kernel = lu.kernel();
|
||||
typename ei_lu_image_impl <MatrixType>::ReturnMatrixType m1image = lu.image();
|
||||
|
||||
std::cout << "rows:" << rows << " cols:" << cols << " | " << rank << " ----- " << lu.rank() << std::endl;
|
||||
VERIFY(rank == lu.rank());
|
||||
VERIFY(cols - lu.rank() == lu.dimensionOfKernel());
|
||||
VERIFY(!lu.isInjective());
|
||||
@ -54,7 +53,8 @@ template<typename MatrixType> void lu_non_invertible()
|
||||
m2 = MatrixType::Random(cols,cols2);
|
||||
m3 = m1*m2;
|
||||
m2 = MatrixType::Random(cols,cols2);
|
||||
m2 = lu.solve(m3);
|
||||
// test that the code, which does resize(), may be applied to an xpr
|
||||
m2.block(0,0,cols,cols2) = lu.solve(m3);
|
||||
VERIFY_IS_APPROX(m3, m1*m2);
|
||||
|
||||
typedef Matrix<typename MatrixType::Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> SquareMatrixType;
|
||||
|
Loading…
x
Reference in New Issue
Block a user