Commits

Sergey Astanin committed 08c663e

Fixed symmetric complement in array format.

Comments (0)

Files changed (1)

src/Data/MatrixMarket.hs

 -- | Construct a list of non-zero entries (without symmetric entries).
 toList :: (MValue a) => Matrix a -> [((Int, Int), a)]
 toList (MM (CoordinateM cm) _ _ _) = cm'values cm
-toList (MM (ArrayM am) _ _ _) =
+toList (MM (ArrayM am) _ General _) =  -- all elements
     let nrs = am'rows am
         ncs = am'cols am
     in  zip [ (r,c) | c<-[1..ncs], r<-[1..nrs] ] $ am'values am
+toList (MM (ArrayM am) _ _ _) =  -- only elements below diagonal
+    let nrs = am'rows am
+        ncs = am'cols am
+    in  zip [ (r,c) | c<-[1..ncs], r<-[c..nrs] ] $ am'values am
+
 
 -- | Construct a list of all non-zero entries (including symmetric entries).
 toCompleteList :: (MValue a) => Matrix a -> [((Int, Int), a)]