# Revision history [back]

### Count number of ones in a set of matrix

I am having the following code:

v = MatrixSpace(GF(2),2,2)
c = [0]*2
for vv in v.list():
t=sum(vv)
c = [x+y for x,y in zip(c,t)]
print c


My goal is to count how many '1s' that I have for each column within the set of matrices. For example with the first 4 matrices in the set:

[0 0]  [1 0]  [0 1]  [0 0]
[0 0], [0 0], [0 0], [1 0]


I expect to receive [2,1] as a result, i.e. there are 2 of '1s' appear in the 1st column and 1 of '1s' appears in the 2nd column. However, I got [0, 1], because it's binary base.

Thank you for reading my problem and support :)