1 | initial version |
Let's use sets. Matrices must be made "immutable" to be members of sets, so:
B_list = [random_matrix(ZZ, 3) for n in range(8)]
for b in B_list:
b.set_immutable()
B = set(B_list)
A_list = B_list[:5]
A = set(A_list)
A combination of size 1 is just an element of the set, or if you like, Y
will range over all subsets of B
of size 1. Then we can choose X
to range over all size 3 subsets of A
but with Y
removed:
for y in B:
X = Combinations(A.difference(set([y]))
for x in X:
# now combine the combination x with the matrix y however you would like
print(x, y)
You can also form a set of these combinations and update it with a new set formed with x
and y
— a set since presumably you don't care about the order among y
and the elements of x
. Since sets ignore duplicates, you will only get unique combinations.
2 | No.2 Revision |
Let's use sets. Matrices must be made "immutable" to be members of sets, so:
B_list = [random_matrix(ZZ, 3) for n in range(8)]
for b in B_list:
b.set_immutable()
B = set(B_list)
A_list = B_list[:5]
A = set(A_list)
A combination of size 1 is just an element of the set, or if you like, Y
will range over all subsets of B
of size 1. Then we can choose X
to range over all size 3 subsets of A
but with Y
removed:
for y in B:
X = Combinations(A.difference(set([y]))
Combinations(A.difference(set([y]), 3)
for x in X:
# now combine the combination x with the matrix y however you would like
print(x, y)
You can also form a set of these combinations and update it with a new set formed with x
and y
— a set since presumably you don't care about the order among y
and the elements of x
. Since sets ignore duplicates, you will only get unique combinations.
3 | No.3 Revision |
Let's use sets. Matrices must be made "immutable" to be members of sets, so:
B_list = [random_matrix(ZZ, 3) for n in range(8)]
for b in B_list:
b.set_immutable()
B = set(B_list)
A_list = B_list[:5]
A = set(A_list)
A combination of size 1 is just an element of the set, or if you like, Y
will range over all subsets of B
of size 1. Then we can choose X
to range over all size 3 subsets of A
but with Y
removed:
for y in B:
X = Combinations(A.difference(set([y]), Combinations(A.difference(set([y])), 3)
for x in X:
# now combine the combination x with the matrix y however you would like
print(x, y)
You can also form a set of these combinations and update it with a new set formed with x
and y
— a set since presumably you don't care about the order among y
and the elements of x
. Since sets ignore duplicates, you will only get unique combinations.