This forum has been archived. All content is frozen. Please use KDE Discuss instead.

.sum() crashed with complex sparse vector

Tags: None
(comma "," separated)
changyan
Registered Member
Posts
6
Karma
0
Hi everyone,
I found the .sum() method crashed with either complex sparse vector or matrix, has anyone encountered with it?

Yan
changyan
Registered Member
Posts
6
Karma
0
I debug it in vs2013, and the program crashed pointing this line:
template<> EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(const double* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_pd(from); }
which is inside of file 'Eigen\src\Core\arch\SSE\PacketMath.h'
changyan
Registered Member
Posts
6
Karma
0
The test code is as follow:

Code: Select all
typedef std::complex<double> cd;
typedef SparseVector<cd> SpVecXcd;
SpVecXcd m(4);
  m.insert(2) = cd(1, 0);
  m.insert(3) = cd(1, -1);
  cout << m.sum();
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
What about the following patch:
Code: Select all
diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h
--- a/Eigen/src/Core/Redux.h
+++ b/Eigen/src/Core/Redux.h
@@ -202,17 +202,17 @@ struct redux_impl<Func, Derived, LinearV
 
   static Scalar run(const Derived& mat, const Func& func)
   {
     const Index size = mat.size();
     eigen_assert(size && "you are using an empty matrix");
     const Index packetSize = packet_traits<Scalar>::size;
     const Index alignedStart = internal::first_aligned(mat);
     enum {
-      alignment = bool(Derived::Flags & DirectAccessBit) || bool(Derived::Flags & AlignedBit)
+      alignment = (bool(Derived::Flags & DirectAccessBit) && bool(packet_traits<Scalar>::AlignedOnScalar)) || bool(Derived::Flags & AlignedBit)
                 ? Aligned : Unaligned
     };
     const Index alignedSize2 = ((size-alignedStart)/(2*packetSize))*(2*packetSize);
     const Index alignedSize = ((size-alignedStart)/(packetSize))*(packetSize);
     const Index alignedEnd2 = alignedStart + alignedSize2;
     const Index alignedEnd  = alignedStart + alignedSize;
     Scalar res;
     if(alignedSize)


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]