* let a = foo() work when a is a row-vector xpr and foo() returns a ReturnByValue col-vector

* remove a few useless resize() in evalTo() implementations
This commit is contained in:
Benoit Jacob 2010-03-08 10:34:59 -05:00
parent 3565e89be2
commit 4293a4d1af
5 changed files with 7 additions and 10 deletions

View File

@ -232,17 +232,19 @@ class DenseStorageBase : public _Base<Derived>
* remain row-vectors and vectors remain vectors.
*/
template<typename OtherDerived>
EIGEN_STRONG_INLINE void resizeLike(const DenseBase<OtherDerived>& other)
EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other)
{
const OtherDerived& other = _other.derived();
const int othersize = other.rows()*other.cols();
if(RowsAtCompileTime == 1)
{
ei_assert(other.rows() == 1 || other.cols() == 1);
resize(1, other.size());
resize(1, othersize);
}
else if(ColsAtCompileTime == 1)
{
ei_assert(other.rows() == 1 || other.cols() == 1);
resize(other.size(), 1);
resize(othersize, 1);
}
else resize(other.rows(), other.cols());
}
@ -343,7 +345,7 @@ class DenseStorageBase : public _Base<Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived> &other)
{
resize(other.derived().rows(), other.derived().cols());
_resize_to_match(other);
Base::operator=(other.derived());
return this->derived();
}
@ -424,7 +426,7 @@ class DenseStorageBase : public _Base<Derived>
* remain row-vectors and vectors remain vectors.
*/
template<typename OtherDerived>
EIGEN_STRONG_INLINE void _resize_to_match(const DenseBase<OtherDerived>& other)
EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other)
{
#ifdef EIGEN_NO_AUTOMATIC_RESIZING
ei_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())

View File

@ -439,8 +439,6 @@ struct ei_solve_retval<PartialPivLU<_MatrixType>, Rhs>
const int size = dec().matrixLU().rows();
ei_assert(rhs().rows() == size);
dst.resize(size, rhs().cols());
// Step 1
dst = dec().permutationP() * rhs();

View File

@ -432,7 +432,6 @@ struct ei_solve_retval<ColPivHouseholderQR<_MatrixType>, Rhs>
{
const int rows = dec().rows(), cols = dec().cols(),
nonzero_pivots = dec().nonzeroPivots();
dst.resize(cols, rhs().cols());
ei_assert(rhs().rows() == rows);
if(nonzero_pivots == 0)

View File

@ -341,7 +341,6 @@ struct ei_solve_retval<FullPivHouseholderQR<_MatrixType>, Rhs>
template<typename Dest> void evalTo(Dest& dst) const
{
const int rows = dec().rows(), cols = dec().cols();
dst.resize(cols, rhs().cols());
ei_assert(rhs().rows() == rows);
// FIXME introduce nonzeroPivots() and use it here. and more generally,

View File

@ -217,7 +217,6 @@ struct ei_solve_retval<HouseholderQR<_MatrixType>, Rhs>
template<typename Dest> void evalTo(Dest& dst) const
{
const int rows = dec().rows(), cols = dec().cols();
dst.resize(cols, rhs().cols());
const int rank = std::min(rows, cols);
ei_assert(rhs().rows() == rows);