1 | initial version |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?
H = matrix(2,2, [1, 1,1, -1])
show("H=",H)
n = int(input("Enter the order of the matrix H : "))
V = GF(2)^(n^2)
R1=V.list()[1:] #We are removing the all-zero list because not needed for our purpose
R2=R1[:-1] #We are removing the all-ones list because not needed for our purpose
A = [] for v in R2: A.append(matrix(ZZ,n,n,v)) #Here we are forming n by n matrices from list in R2
B=[] for a in A: b=-a B.append(b)
#by taking their negative.
#This contains all 0,-1 matrices
C = [] for a in A: C.append(a) for b in B: C.append(b)
test_sum = int(input("Into how many matrices you want to break H :"))
test_comb = Combinations(C,test_sum) # Here we are forming all "test_sum"-set combinations from C". That is if #test_sum =3, then test_comb, gives all 3 set combinations from C"
for t in test_comb: if (sum(t)==H): #Checking which combinations in test_sum give the sum = H and printing those
print("A combination is: ")
show(t)
print("\n")
2 | No.2 Revision |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?
H = matrix(2,2, [1, 1,1, -1])
show("H=",H)
n = int(input("Enter the order of the matrix H : "))
V = GF(2)^(n^2)
R1=V.list()[1:] #We are removing the all-zero list because not needed for our purpose
R2=R1[:-1] #We are removing the all-ones list because not needed for our purpose
A = [] for v in R2: A.append(matrix(ZZ,n,n,v)) # Forming n by n matrices from list in R2. Contains all 0,1 matrices
B=[]
for a in A:
b=-a
B.append(b)
#Here we are forming n by n matrices from list in R2
B=[] for a in A: b=-a B.append(b)
#by taking their negative.
#This negative. his contains all 0,-1 matrices
matrices C = []
for a in A:
C.append(a)
for b in B:
C.append(b)
test_sum = int(input("Into how many matrices you want to break H :"))
test_comb = Combinations(C,test_sum) # Here we are forming all "test_sum"-set combinations from C". That is if #test_sum =3, then test_comb, gives all 3 set combinations from C"
for t in test_comb: if (sum(t)==H): #Checking which combinations in test_sum give the sum = H and printing those
print("A combination is: ")
show(t)
print("\n")
3 | No.3 Revision |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?
H = matrix(2,2, [1, 1,1, -1])
show("H=",H)
n = int(input("Enter the order of the matrix H : "))
V = GF(2)^(n^2)
R1=V.list()[1:]
#We are removing the all-zero list because not needed for our purpose
R2=R1[:-1]
#We are removing the all-ones list because not needed for our purpose
A = []
for v in R2:
A.append(matrix(ZZ,n,n,v))
# Forming n by n matrices from list in R2. Contains all 0,1 matricesmatrices.
B=[]
for a in A:
b=-a
B.append(b)
#Here we are forming # Forming n by n matrices from A by taking their negative. his contains Contains all 0,-1 matrices
C = []
for a in A:
C.append(a)
for b in B:
C.append(b)
#Here we are taking the C.append(b) #Taking union of A and B
test_sum = int(input("Into how many matrices you want to break H :"))
test_comb = Combinations(C,test_sum)
# Here we are forming all "test_sum"-set combinations from C".
# That is is, if
#test_sum test_sum =3, then test_comb, gives all 3 set combinations from C"
for t in test_comb:
if (sum(t)==H):
#Checking which combinations in test_sum give the sum = H and printing those
print("A combination is: ")
show(t)
print("\n")
4 | No.4 Revision |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?
#Write
your show("H=",H)
5 | No.5 Revision |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?
#Write faster?(Please note that after writing the code it appeared differently in preview, I tried changing but could not. So indentation is required where B and C are mentioned.) Write
your matrix
matrix H = matrix(2,2, [1, 1,1, -1])
show("H=",H)
show("H=",H)
n = int(input("Enter the order of the matrix H : "))
")) V = GF(2)^(n^2) R1=V.list()[1:]
#We are removing the all-zero list because not needed for our purpose
purpose R2=R1[:-1]
#We are removing the all-ones list because not needed for our purpose
purpose A = []
for v in R2:
A.append(matrix(ZZ,n,n,v))
# Forming n by n matrices from list in R2. Contains all 0,1 matrices
matrices. B=[]
for a in A:
b=-a
B.append(b)
#Here we are forming A:
b=-a # Forming n by n matrices from A by taking their negative. his contains Contains all 0,-1 matrices
B.append(b) C = []
for a in A:
C.append(a)
for b in B:
C.append(b) #Here we are taking the union #Union of A and B
B test_sum = int(input("Into how many matrices you want to break H :"))
:")) test_comb = Combinations(C,test_sum)
Combinations(C,test_sum)
# Here we are forming all "test_sum"-set combinations from C".
# That is is, if
# test_sum =3, then test_comb, gives all 3 set combinations from C" for t in test_comb:
if (sum(t)==H): # Checking
#Checking which combinations in test_sum give the sum = H and printing those
those
print("A combination is: ")
show(t)
print("\n")
6 | No.6 Revision |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?(Please note that after writing the code it appeared differently in preview, I tried changing but could not. So indentation is required where B and C are mentioned.)
#Write
your show("H=",H)
7 | No.7 Revision |
I asked this thing because a friend of mine made code for this but it is very time taking. For 2nd order matrices output comes out instantly. For 3rd order , output starts coming but it is taking a lot of time. For 4th order , no output is shown even after hours. Since for 2nd order, number of elements in V.List is 2^4, for 3rd order it is 2^9 and for 4th order it is 2^16 so it is time taking. Can any change be made to make this code run faster?(Please note that after writing the code it appeared differently in preview, I tried changing but could not. So indentation is required where B and C are mentioned.)
#Write your matrix
H = matrix(2,2, [1, 1,1, -1])
show("H=",H)
n = int(input("Enter the order of the matrix H : "))
V = GF(2)^(n^2)
R1=V.list()[1:]
#We are removing the all-zero list because not needed for our purpose
R2=R1[:-1]
#We are removing the all-ones list because not needed for our purpose
A = []
for v in R2:
A.append(matrix(ZZ,n,n,v))
# Forming n by n matrices from list in R2. Contains all 0,1 matrices.
B=[]
for a in A:
b=-a # Forming n by n matrices from A by taking their negative. Contains all 0,-1 matrices
B.append(b)
C = []
for a in A:
C.append(a)
for b in B:
C.append(b) #Union of A and B
test_sum = int(input("Into how many matrices you want to break H :"))
test_comb = Combinations(C,test_sum)
# Here we are forming all "test_sum"-set combinations from C".
# That is, if test_sum =3, then test_comb, gives all 3 set combinations from C"
for t in test_comb:
if (sum(t)==H):
#Checking which combinations in test_sum give the sum = H and printing those
print("A combination is: ")
show(t)
print("\n")
#Write your matrix
H = matrix(2,2, [1, 1,1, -1])
show("H=",H)
n = int(input("Enter the order of the matrix H : "))
V = GF(2)^(n^2)
R1=V.list()[1:]
#We are removing the all-zero list because not needed for our purpose
R2=R1[:-1]
#We are removing the all-ones list because not needed for our purpose
A = []
for v in R2:
A.append(matrix(ZZ,n,n,v))
# Forming n by n matrices from list in R2. Contains all 0,1 matrices.
B=[]
for a in A:
b=-a
B.append(b)
# Forming n by n matrices from A by taking their negative. Contains all 0,-1 matrices
test_sum = int(input("Into how many matrices you want to break H :"))
num_nonneg = int(input("How many non-negative matrices u want :"))
num_nonpos = (test_sum)-(num_nonneg)
nonneg_comb = Combinations(A,num_nonneg)
nonpos_comb = Combinations(B,num_nonpos)
for x in nonneg_comb:
for y in nonpos_comb:
if (sum(x+y)==H):
print("A combination is: ")
show(x+y)
print("\n")
print("No Combination exists")