mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 20:26:03 +08:00
Guard against transposeInPlace on non-square non-resizable matrix.
Inspired by question by Martin Drozdik at stackoverflow.com/q/14954983
This commit is contained in:
parent
a054b4ee27
commit
986f60127d
@ -278,7 +278,7 @@ struct inplace_transpose_selector<MatrixType,false> { // non square matrix
|
|||||||
* m = m.transpose().eval();
|
* m = m.transpose().eval();
|
||||||
* \endcode
|
* \endcode
|
||||||
* and is faster and also safer because in the latter line of code, forgetting the eval() results
|
* and is faster and also safer because in the latter line of code, forgetting the eval() results
|
||||||
* in a bug caused by aliasing.
|
* in a bug caused by \ref TopicAliasing "aliasing".
|
||||||
*
|
*
|
||||||
* Notice however that this method is only useful if you want to replace a matrix by its own transpose.
|
* Notice however that this method is only useful if you want to replace a matrix by its own transpose.
|
||||||
* If you just need the transpose of a matrix, use transpose().
|
* If you just need the transpose of a matrix, use transpose().
|
||||||
@ -289,6 +289,8 @@ struct inplace_transpose_selector<MatrixType,false> { // non square matrix
|
|||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
inline void DenseBase<Derived>::transposeInPlace()
|
inline void DenseBase<Derived>::transposeInPlace()
|
||||||
{
|
{
|
||||||
|
eigen_assert((rows() == cols() || (RowsAtCompileTime == Dynamic && ColsAtCompileTime == Dynamic))
|
||||||
|
&& "transposeInPlace() called on a non-square non-resizable matrix");
|
||||||
internal::inplace_transpose_selector<Derived>::run(derived());
|
internal::inplace_transpose_selector<Derived>::run(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user