Mercurial > hg > may
comparison yetilab/matrix/matrix.yeti @ 159:a9d58d9c71ca
Fix matrix.equal (did not check matrix size, could return true if one was a subset of the other) and add test for it; fix resizedTo test
author | Chris Cannam |
---|---|
date | Wed, 01 May 2013 12:32:08 +0100 |
parents | b6db07468ed1 |
children | 38938ca5db0c |
comparison
equal
deleted
inserted
replaced
158:b6db07468ed1 | 159:a9d58d9c71ca |
---|---|
99 fi; | 99 fi; |
100 | 100 |
101 // Matrices with different storage order but the same contents are | 101 // Matrices with different storage order but the same contents are |
102 // equal (but comparing them is slow) | 102 // equal (but comparing them is slow) |
103 equal m1 m2 = | 103 equal m1 m2 = |
104 if m1.isRowMajor? != m2.isRowMajor? | 104 if m1.size != m2.size then false |
105 then equal (flipped m1) m2; | 105 elif m1.isRowMajor? != m2.isRowMajor? then equal (flipped m1) m2; |
106 else | 106 else |
107 compare d1 d2 = all id (map2 vec.equal d1 d2); | 107 compare d1 d2 = all id (map2 vec.equal d1 d2); |
108 case m1.data of | 108 case m1.data of |
109 RowM d1: case m2.data of RowM d2: compare d1 d2; _: false; esac; | 109 RowM d1: case m2.data of RowM d2: compare d1 d2; _: false; esac; |
110 ColM d1: case m2.data of ColM d2: compare d1 d2; _: false; esac; | 110 ColM d1: case m2.data of ColM d2: compare d1 d2; _: false; esac; |