@@ -71,6 +71,7 @@ class PermutationBase : public EigenBase<Derived>
7171
7272 /* * Copies the other permutation into *this */
7373 template <typename OtherDerived>
74+ EIGEN_DEVICE_FUNC
7475 Derived& operator =(const PermutationBase<OtherDerived>& other)
7576 {
7677 indices () = other.indices ();
@@ -79,6 +80,7 @@ class PermutationBase : public EigenBase<Derived>
7980
8081 /* * Assignment from the Transpositions \a tr */
8182 template <typename OtherDerived>
83+ EIGEN_DEVICE_FUNC
8284 Derived& operator =(const TranspositionsBase<OtherDerived>& tr)
8385 {
8486 setIdentity (tr.size ());
@@ -87,6 +89,18 @@ class PermutationBase : public EigenBase<Derived>
8789 return derived ();
8890 }
8991
92+ #ifndef EIGEN_PARSED_BY_DOXYGEN
93+ /* * This is a special case of the templated operator=. Its purpose is to
94+ * prevent a default operator= from hiding the templated operator=.
95+ */
96+ EIGEN_DEVICE_FUNC
97+ Derived& operator =(const PermutationBase& other)
98+ {
99+ indices () = other.indices ();
100+ return derived ();
101+ }
102+ #endif
103+
90104 /* * \returns the number of rows */
91105 inline EIGEN_DEVICE_FUNC Index rows () const { return Index (indices ().size ()); }
92106
@@ -116,18 +130,22 @@ class PermutationBase : public EigenBase<Derived>
116130 }
117131
118132 /* * const version of indices(). */
133+ EIGEN_DEVICE_FUNC
119134 const IndicesType& indices () const { return derived ().indices (); }
120135 /* * \returns a reference to the stored array representing the permutation. */
136+ EIGEN_DEVICE_FUNC
121137 IndicesType& indices () { return derived ().indices (); }
122138
123139 /* * Resizes to given size.
124140 */
141+ EIGEN_DEVICE_FUNC
125142 inline void resize (Index newSize)
126143 {
127144 indices ().resize (newSize);
128145 }
129146
130147 /* * Sets *this to be the identity permutation matrix */
148+ EIGEN_DEVICE_FUNC
131149 void setIdentity ()
132150 {
133151 StorageIndex n = StorageIndex (size ());
@@ -137,6 +155,7 @@ class PermutationBase : public EigenBase<Derived>
137155
138156 /* * Sets *this to be the identity permutation matrix of given size.
139157 */
158+ EIGEN_DEVICE_FUNC
140159 void setIdentity (Index newSize)
141160 {
142161 resize (newSize);
@@ -171,10 +190,11 @@ class PermutationBase : public EigenBase<Derived>
171190 *
172191 * \sa applyTranspositionOnTheLeft(Index,Index)
173192 */
193+ EIGEN_DEVICE_FUNC
174194 Derived& applyTranspositionOnTheRight (Index i, Index j)
175195 {
176196 eigen_assert (i>=0 && j>=0 && i<size () && j<size ());
177- std ::swap (indices ().coeffRef (i), indices ().coeffRef (j));
197+ numext ::swap (indices ().coeffRef (i), indices ().coeffRef (j));
178198 return derived ();
179199 }
180200
@@ -307,21 +327,31 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
307327 typedef typename Traits::StorageIndex StorageIndex;
308328 #endif
309329
330+ EIGEN_DEVICE_FUNC
310331 inline PermutationMatrix ()
311332 {}
312333
313334 /* * Constructs an uninitialized permutation matrix of given size.
314335 */
336+ EIGEN_DEVICE_FUNC
315337 explicit inline PermutationMatrix (Index size) : m_indices(size)
316338 {
317339 eigen_internal_assert (size <= NumTraits<StorageIndex>::highest ());
318340 }
319341
320342 /* * Copy constructor. */
321343 template <typename OtherDerived>
344+ EIGEN_DEVICE_FUNC
322345 inline PermutationMatrix (const PermutationBase<OtherDerived>& other)
323346 : m_indices(other.indices()) {}
324347
348+ #ifndef EIGEN_PARSED_BY_DOXYGEN
349+ /* * Standard copy constructor. Defined only to prevent a default copy constructor
350+ * from hiding the other templated constructor */
351+ EIGEN_DEVICE_FUNC
352+ inline PermutationMatrix (const PermutationMatrix& other) : m_indices(other.indices()) {}
353+ #endif
354+
325355 /* * Generic constructor from expression of the indices. The indices
326356 * array has the meaning that the permutations sends each integer i to indices[i].
327357 *
@@ -330,11 +360,13 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
330360 * array's size.
331361 */
332362 template <typename Other>
363+ EIGEN_DEVICE_FUNC
333364 explicit inline PermutationMatrix (const MatrixBase<Other>& indices) : m_indices(indices)
334365 {}
335366
336367 /* * Convert the Transpositions \a tr to a permutation matrix */
337368 template <typename Other>
369+ EIGEN_DEVICE_FUNC
338370 explicit PermutationMatrix (const TranspositionsBase<Other>& tr)
339371 : m_indices(tr.size())
340372 {
@@ -343,6 +375,7 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
343375
344376 /* * Copies the other permutation into *this */
345377 template <typename Other>
378+ EIGEN_DEVICE_FUNC
346379 PermutationMatrix& operator =(const PermutationBase<Other>& other)
347380 {
348381 m_indices = other.indices ();
@@ -351,17 +384,32 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
351384
352385 /* * Assignment from the Transpositions \a tr */
353386 template <typename Other>
387+ EIGEN_DEVICE_FUNC
354388 PermutationMatrix& operator =(const TranspositionsBase<Other>& tr)
355389 {
356390 return Base::operator =(tr.derived ());
357391 }
358392
393+ #ifndef EIGEN_PARSED_BY_DOXYGEN
394+ /* * This is a special case of the templated operator=. Its purpose is to
395+ * prevent a default operator= from hiding the templated operator=.
396+ */
397+ EIGEN_DEVICE_FUNC
398+ PermutationMatrix& operator =(const PermutationMatrix& other)
399+ {
400+ m_indices = other.m_indices ;
401+ return *this ;
402+ }
403+ #endif
404+
359405 /* * const version of indices(). */
406+ EIGEN_DEVICE_FUNC
360407 const IndicesType& indices () const { return m_indices; }
408+
361409 /* * \returns a reference to the stored array representing the permutation. */
410+ EIGEN_DEVICE_FUNC
362411 IndicesType& indices () { return m_indices; }
363412
364-
365413 /* *** multiplication helpers to hopefully get RVO ****/
366414
367415#ifndef EIGEN_PARSED_BY_DOXYGEN
@@ -374,7 +422,9 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
374422 for (StorageIndex i=0 ; i<end;++i)
375423 m_indices.coeffRef (other.derived ().nestedExpression ().indices ().coeff (i)) = i;
376424 }
425+
377426 template <typename Lhs,typename Rhs>
427+ EIGEN_DEVICE_FUNC
378428 PermutationMatrix (internal::PermPermProduct_t, const Lhs& lhs, const Rhs& rhs)
379429 : m_indices(lhs.indices().size())
380430 {
0 commit comments