Ask Your Question

How to intersect subspaces of a combinatorial free module?

asked 2022-06-08 04:32:59 +0200

peter.xu gravatar image

updated 2022-06-09 16:37:15 +0200

Max Alekseyev gravatar image

Hi, I've defined a CombinatorialFreeModule over ZZ with a pretty large named basis, along with a family of subspaces using .submodule(). In the documentation, I see that the class FreeModule_generic_field has a method .intersection() to intersect these subspaces - is there a way to do this for the combinatorial free modules as well? I can think of some very ugly messy solutions by abandoning the CombinatorialFreeModule class, but I was hoping there'd be a better way.

Here's a toy example:

Z = CombinatorialFreeModule(ZZ, ['a','b','c'], prefix="z") 
z = Z.basis()
Z1 = Z.submodule([z['a'],z['b']])
Z2 = Z.submodule([z['b'],z['c']])

I'd like to be able to write something like Z1.intersection(Z2) to get a submodule containing just z['b']. Of course, the real example has a very large number of submodules with much more complicated generators.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-06-09 19:09:19 +0200

Max Alekseyev gravatar image

I'm not sure if the approach below is best possible, but it does the job. Essentially it lifts bases of Z1 and Z2 into Z, constructs the corresponding vector subspaces, intersects them and embeds the result back into Z.

def subm_intersect(Z1,Z2):
    Z = Z1.basis()[0].lift().parent()
    assert Z == Z2.basis()[0].lift().parent()    # Z1 and Z2 shold have the same parent module

    z = Z.basis()

    V = VectorSpace(QQ, len(z))
    V1 = V.subspace( [[b.lift().coefficient(k) for k in z.keys()] for b in Z1.basis()] )
    V2 = V.subspace( [[b.lift().coefficient(k) for k in z.keys()] for b in Z2.basis()] )
    U = V1.intersection(V2)

    return Z.submodule( [Z.linear_combination(zip(z,u)) for u in U.basis()] )
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2022-06-08 04:32:59 +0200

Seen: 207 times

Last updated: Jun 09 '22