mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 12:15:11 +08:00
Use true compile-time branching in SparseVector::assign to handle automatic transposition.
This commit is contained in:
parent
edba612f68
commit
7d8823c8b7
@ -243,9 +243,9 @@ class SparseVector
|
|||||||
{
|
{
|
||||||
if ( (bool(OtherDerived::IsVectorAtCompileTime) && int(RowsAtCompileTime)!=int(OtherDerived::RowsAtCompileTime))
|
if ( (bool(OtherDerived::IsVectorAtCompileTime) && int(RowsAtCompileTime)!=int(OtherDerived::RowsAtCompileTime))
|
||||||
|| ((!bool(OtherDerived::IsVectorAtCompileTime)) && ( bool(IsColVector) ? other.cols()>1 : other.rows()>1 )))
|
|| ((!bool(OtherDerived::IsVectorAtCompileTime)) && ( bool(IsColVector) ? other.cols()>1 : other.rows()>1 )))
|
||||||
return assign(other.transpose());
|
return assign(other.transpose(), typename internal::conditional<((Flags & RowMajorBit) == (OtherDerived::Flags & RowMajorBit)),internal::true_type,internal::false_type>::type());
|
||||||
else
|
else
|
||||||
return assign(other);
|
return assign(other, typename internal::conditional<((Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit)),internal::true_type,internal::false_type>::type());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
@ -328,7 +328,10 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DONT_INLINE SparseVector& assign(const SparseMatrixBase<OtherDerived>& _other);
|
EIGEN_DONT_INLINE SparseVector& assign(const SparseMatrixBase<OtherDerived>& _other, internal::true_type);
|
||||||
|
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DONT_INLINE SparseVector& assign(const SparseMatrixBase<OtherDerived>& _other, internal::false_type);
|
||||||
|
|
||||||
Storage m_data;
|
Storage m_data;
|
||||||
Index m_size;
|
Index m_size;
|
||||||
@ -400,12 +403,10 @@ class SparseVector<Scalar,_Options,_Index>::ReverseInnerIterator
|
|||||||
|
|
||||||
template<typename Scalar, int _Options, typename _Index>
|
template<typename Scalar, int _Options, typename _Index>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DONT_INLINE SparseVector<Scalar,_Options,_Index>& SparseVector<Scalar,_Options,_Index>::assign(const SparseMatrixBase<OtherDerived>& _other)
|
EIGEN_DONT_INLINE SparseVector<Scalar,_Options,_Index>& SparseVector<Scalar,_Options,_Index>::assign(const SparseMatrixBase<OtherDerived>& _other, internal::true_type)
|
||||||
{
|
{
|
||||||
const OtherDerived& other(_other.derived());
|
const OtherDerived& other(_other.derived());
|
||||||
const bool needToTranspose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
|
|
||||||
if(needToTranspose)
|
|
||||||
{
|
|
||||||
Index size = other.size();
|
Index size = other.size();
|
||||||
Index nnz = other.nonZeros();
|
Index nnz = other.nonZeros();
|
||||||
resize(size);
|
resize(size);
|
||||||
@ -418,12 +419,15 @@ EIGEN_DONT_INLINE SparseVector<Scalar,_Options,_Index>& SparseVector<Scalar,_Opt
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
template<typename Scalar, int _Options, typename _Index>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DONT_INLINE SparseVector<Scalar,_Options,_Index>& SparseVector<Scalar,_Options,_Index>::assign(const SparseMatrixBase<OtherDerived>& _other, internal::false_type)
|
||||||
{
|
{
|
||||||
|
const OtherDerived& other(_other.derived());
|
||||||
// there is no special optimization
|
// there is no special optimization
|
||||||
return Base::operator=(other);
|
return Base::operator=(other);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user